Unreadable var_dump in Firebug when xdebug is enabled

偶尔善良 提交于 2019-12-08 14:54:32

问题


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>

回答1:


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



回答2:


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 );




回答3:


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




回答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.




回答5:


You can use an alternative:

http://raveren.github.io/kint/

It works with zero set-up and has much more features than Xdebug's var_dump anyway.

Screenshot:



来源:https://stackoverflow.com/questions/1465645/unreadable-var-dump-in-firebug-when-xdebug-is-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!