奇怪的 var_dump 行为 [英] Weird var_dump behavior

查看:31
本文介绍了奇怪的 var_dump 行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码行:

var_dump(array());

在一个文件中,它输出:

数组(大小=0)空的

在第二个文件中,它输出:

string '

<b>数组</b><i>(大小=0)</i><i><font color='#888a85'>空</font></i>

'(长度=119)

任何想法是什么导致了第二个文件?当我查看第二个文件的渲染标记的来源时,我看到:

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

UPDATE 1:视图->第一个文件的来源:

<b>数组</b><i>(大小=0)</i><i><font color='#888a85'>空</font></i>

解决方案

var_dump() 替换为 Xdebugs 自定义函数,如下所述:

<块引用>

Xdebug 替换了 PHP 的 var_dump() 函数来显示变量.Xdebug 的版本包括不同类型的不同颜色,并限制了数组元素/对象属性的数量、最大深度和字符串长度.还有一些其他函数处理变量显示.

http://xdebug.org/docs/display

猜猜您不知何故/在您的第二个文件中实现了 xdebug.

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>

解决方案

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.

这篇关于奇怪的 var_dump 行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆