彩色var_dump()和错误 [英] Colored var_dump() and errors
问题描述
如何将样式设置为var_dump()
函数和 PHP 错误样式,就像下一张图片一样?
How can I set style to var_dump()
function and PHP errors style, like on the next image?
此刻,我可以看到var_dump()
的下一个视图(带有<pre>var_dump(...)</pre>
,如果没有,它将全部显示在一行中),并且仅显示纯文本以显示错误.
At the moment I have next view of var_dump()
(with <pre>var_dump(...)</pre>
, without it will be all in one line) and just plain text for errors.
我在某处搜索了PHP颜色错误,var_dump
样式的内容,但找不到任何内容.
I searched something for PHP colored errors, var_dump
styles, but could not find anything.
我将OpenServer用作localhost,在以前的版本中,我具有相同的错误样式,但现在仅是纯文本.定制真的吗?
I used OpenServer as localhost, and on previous version I had same styles for errors, but now just plain text. Is it real to customize?
推荐答案
当您安装并启用 Xdebug :
Xdebug代替了PHP的
var_dump()
函数来显示变量. Xdebug的版本包括用于不同类型的不同颜色,并对数组元素/对象属性的数量,最大深度和字符串长度进行了限制.还有一些其他功能也可以处理变量显示.
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.
您可以使用ini设置xdebug.overload_var_dump
You can enable/disable this with the ini setting xdebug.overload_var_dump
默认情况下,当html_errors php.ini设置设置为1时,Xdebug会使用自己的改进版本重载
var_dump()
来显示变量.如果您不希望这样做,则可以将该设置设置为0,但是首先检查是否关闭html_errors并不聪明.
By default Xdebug overloads
var_dump()
with its own improved version for displaying variables when the html_errors php.ini setting is set to 1. In case you do not want that, you can set this setting to 0, but check first if it's not smarter to turn off html_errors.
查看文档以获取更多信息.
Check the documentation for further information.
请注意,您不想在生产服务器上安装Xdebug扩展,因为它会大大降低代码执行速度.
Note that you do not want to have the Xdebug extension installed on a production server as it will significantly slow down code execution.
这篇关于彩色var_dump()和错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!