就在最近,PHP 中的 var_dump()(目前使用 5.6.23)开始在实际转储我的变量之前打印出文件名和行号。我不知道服务器上有任何重大变化,所以我想知道为什么会发生这种情况,而且在网络或 PHP 文档 ( var_dump() ) 中也找不到任何内容
使用命令行时也会发生奇怪的行为:
> php -r 'var_dump("lol");'
Command line code:1:
string(3) "lol"
虽然我只是习惯于打印“string(3) “lol””。
这不是一个障碍,但打破了我的几个单元测试,我需要比较一些来自使用 var_dump() 打印的 API 的输出。 我最初认为它可能与 xdebug 有关,但找不到任何似乎与此问题相关的指令。
感谢任何导致此问题的提示。
最佳答案
您已启用 xdebug。
One of the new features relates to one of the first things that I added in the original Xdebug: making the var_dump() output "pretty". Xdebug replaces PHP's standard var_dump() function with its own version, as long as the xdebug.overload_var_dump setting is not set to 0
Xdebug 2.3 enhances the overloading of var_dump() with the inclusion of the file name and line number where var_dump() is called at. This has been a long standing feature request.
这是我没有 xdebug 的输出;
>php -r "var_dump('lol')";
string(3) "lol"
关于php - 为什么 var_dump 显示文件名和行号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38375389/