Xdebug Chrome预览无法正确呈现响应,仅显示一行

时间:2019-02-15 14:16:38

标签: php google-chrome xdebug

Chrome预览无法正确呈现响应,因为昨天我将工作机从Win 8升级到Win10。请查看屏幕截图:

enter image description here

enter image description here

如您所见,只渲染了对象的一行,当我用一个简单的数组尝试它时,发生了同样的事情,它只渲染了单词“ array”和“ 0”;

我正在使用Chrome 72.0.3626.96,WampServer64和PHP 7.2.14,这些是我在php.ini中的Xdebug设置:

zend_extension="c:/wamp64/bin/php/php7.2.14/zend_ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll"

xdebug.default_enable=1
html_errors = On
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9123
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024 

它实际上是在一天前获得Windows 10的。Chrome漏洞或我做错了什么?

1 个答案:

答案 0 :(得分:2)

我发现了问题,这很奇怪。看起来最新版本的Chrome(对我来说是72.0.3626.119)在响应文本的输出中带有哈希字符(#)时,无法呈现预览。它将愉快地渲染所有内容,直到遇到哈希字符为止。这绝对是Chrome中的错误。

我是通过首先注意到预览在<font color='#888a85'>=&gt;</font>停下来发现了这一点。我在文档中对此进行了硬编码,并删除了字符,直到得出结论是引起问题的哈希字符为止。

这里是该bug的演示。在最新版本的Chrome浏览器中运行此代码段并打开Inspector时,您应该在网络标签中看到该请求的弹出窗口。当您单击请求并转到“预览”选项卡时,第三段将被截断,因为它前面紧跟着#

<p>Para1</p>
<p>Para2</p>
#
<p>Para3</p>

我无法找到与此相关的公开错误报告,因此我选择在这里进行报告:https://bugs.chromium.org/p/chromium/issues/detail?id=936284

该问题似乎已经报告(link),并已在Chrome开发版本中修复,但尚未在稳定版本中更新。

同时,如果您确实需要在Chrome中运行var_dump,则可以将其作为解决方法(缓冲输出并替换#的实例):

ob_start();
var_dump($var);
echo str_replace('#','',$ob_get_clean());

...或者您可以关闭HTML错误:

ini_set('html_errors', false);