Why does var_dump show the file name and line number?

More recently, var_dump () in PHP (currently using 5.6.23) began to print the file name as well as the line number before actually resetting my variable. I don’t know of any major changes on the server, so I was wondering why this is happening and there is nothing to find on the Internet or in the PHP documentation ( var_dump () )

Strange behavior also occurs when using the command line:

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

So far, I'm just used to "print line (3)" lol ".

This is not showstopper, but broke a couple of my unit tests, where I needed to compare some data from the API that prints with var_dump (). At first I thought it might be related to xdebug, but could not find any directive that seems to be related to this problem.

Any hint of what causes this is appreciated.

+5
source share
1 answer

You have xdebug enabled.

One of the new features relates to one of the first things I added to the original Xdebug: make var_dump () output "pretty." Xdebug replaces the PHP standard var_dump () function with its own versions if xdebug.overload_var_dump is not set to 0


Xdebug 2.3 increases the overload of var_dump () by including the file name and line number where var_dump () is called. This was a long-standing feature request.

Here is my conclusion without xdebug;

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

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

+6
source

All Articles