为什么var_dump显示文件名和行号? [英] Why does var_dump show filename and line number?

查看:299
本文介绍了为什么var_dump显示文件名和行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,PHP(当前使用5.6.23)中的var_dump()开始打印文件名以及行号,然后才实际转储变量.我不知道服务器上的任何重大更改,所以我想知道为什么会发生这种情况,在Web上或PHP文档中也找不到任何内容(

Just recently var_dump() in PHP (currently using 5.6.23) started to print out the filename as well as the line number before actually dumping my variable. I'm not aware of any major changes on the server, so I was wondering why this happens, also there's nothing to be found on the web or in the PHP-documentation (var_dump())

使用命令行时也会发生奇怪的行为:

The strange behaviour also happens when using the command line:

 > php -r 'var_dump("lol");'
 Command line code:1:
 string(3) "lol"

虽然我只是习惯于打印"string(3)" lol".

While I'm just used to "string(3) "lol"" being printed.

这不是最主要的方法,但是打破了我的一些单元测试,在这里我需要比较使用var_dump()打印的API的一些输出. 我首先以为它可能与xdebug有关,但找不到与该问题有关的任何指令.

This is not a showstopper but broke a couple of my unit-tests where I needed to compare some output from an API which is printed using var_dump(). I first thought it could be related to xdebug, but couldn't find any directive that seemd to be related to this problem.

任何提示都是由什么引起的.

Any hint what is causing this is appreciated.

推荐答案

您已启用xdebug.

其中一项新功能与我第一件事有关 在原始Xdebug中添加:使var_dump()输出漂亮". Xdebug用自己的PHP取代了标准的PHP var_dump()函数 版本,只要xdebug.overload_var_dump设置未设置为 0


Xdebug 2.3通过包含以下内容增强了var_dump()的重载 调用var_dump()的文件名和行号.这 长期以来一直是功能请求.

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的输出;

Here is my output without xdebug;

>php -r "var_dump('lol')";
string(3) "lol"

https://derickrethans.nl/xdebug-2.3-overload-vardump.html

这篇关于为什么var_dump显示文件名和行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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