Weird var_dump behavior

老子叫甜甜 提交于 2019-12-23 13:07:12

问题


I have the following line of code:

var_dump(array());

In one file, it outputs this:

array (size=0)
  empty

In the second file, it outputs this:

string '<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b> <i>(size=0)</i>
  <i><font color='#888a85'>empty</font></i>
</pre>' (length=119)

Any ideas what's causing this in the second file? When I view the source of the rendered markup of the second file, I see this:

<pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font color='#cc0000'>'&lt;pre class=&#39;xdebug-var-dump&#39; dir=&#39;ltr&#39;&gt;&#10;&lt;b&gt;array&lt;/b&gt; &lt;i&gt;(size=0)&lt;/i&gt;&#10;  &lt;i&gt;&lt;font color=&#39;#888a85&#39;&gt;empty&lt;/font&gt;&lt;/i&gt;&#10;&lt;/pre&gt;'</font> <i>(length=119)</i>
</pre>

UPDATE 1: the view -> source of the first file:

<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b> <i>(size=0)</i>
  <i><font color='#888a85'>empty</font></i>
</pre>

回答1:


var_dump() is replaced by Xdebugs custom function, as mentioned here:

Xdebug replaces PHP's var_dump() function for displaying variables. Xdebug's version includes different colors for different types and places limits on the amount of array elements/object properties, maximum depth and string lengths. There are a few other functions dealing with variable display as well.

http://xdebug.org/docs/display

Guess you're somehow/where implementing xdebug in your second file.



来源:https://stackoverflow.com/questions/15666916/weird-var-dump-behavior

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