Unreadable var_dump in Firebug when xdebug is enabled
Asked Answered
G

6

15

Xdebug displays "var_dump" in its own way with more useful information, but in Firebug is unreadable.

I was wondering if there was a way to display the var_dump in Firebug to make it readable without disabling xdebug and also keeping the display of the var_dump made by xdebug in PHP.

Examples of var_dump displayed in Firebug:

$test = array('id' => '42', 'name' => 'Mao');
var_dump($test);

Default :

array(2) {
  ["id"]=>
  string(2) "42"
  ["name"]=>
  string(3) "Mao"
}

Xdebug :

<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b>
  'id' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'42'</font> <i>(length=2)</i>
  'name' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'Mao'</font> <i>(length=3)</i>
</pre>
Granuloma answered 23/9, 2009 at 12:18 Comment(3)
What does 'unreadable' mean? No output at all? Messed-up output? Missing pieces? ...Foreshorten
Html are added to the var_dump, in Firebug it's more difficult to read the output.Granuloma
Are you using FirePHP? As far as I know FirePHP is able to pretty-print PHP objects and arrays so there is no need to run them through var_dump()Foreshorten
F
9

You can switch off Xdebug-var_dump()-overloading by setting xdebug.overload_var_dump to false. Then you can use var_dump() when you don't need the additional HTML-formatting and xdebug_var_dump() when you require a fully formatted debug output.

But as I wrote in my comment above, if you're using FirePHP, you can simply let FirePHP format the output in your Firebug console:

fb($variable, FirePHP::DUMP) // or
FB::dump('Key', $variable) // or
$firephp->dump('Key', $variable); // where $firephp is your FirePHP instance
Foreshorten answered 23/9, 2009 at 13:5 Comment(0)
P
9

Mike B's solution,

ini_set('xdebug.overload_var_dump', 0);

didn't work with my install.

But i can do this to supress the html :

ini_set( 'html_errors' , 0 );

Panoptic answered 29/8, 2010 at 14:17 Comment(0)
C
6

Setting xdebug.overload_var_dump="0" in php.ini solved the problem in my case.

Conversational answered 27/5, 2012 at 10:58 Comment(0)
H
4

ini_set('xdebug.overload_var_dump', 0); doesn't work here either. ini_set( 'html_errors' , 0 ); does work but it can be very slow sometimes.

As a simple workaround you might use this:

echo var_export($this);

Which is just 7 keypresses more than the normal var_dump.

Hanging answered 1/12, 2010 at 16:34 Comment(0)
S
1

I'm using wampserver 3.2.6, edited php.ini to:

xdebug.overload_var_dump=off

did nothing for me. But this one worked:

xdebug.mode=off

Now have outputs with no formating

Spatola answered 7/12, 2022 at 8:20 Comment(0)
H
1

I had this problem for some time after using Wampserver, you left-click on the Wampserver icon, then:

PHP -> PHP settings -> xdebug.mode -> off

Disable xdebug.mode according to the picture enter image description here

Haaf answered 7/4, 2023 at 15:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.