Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does var_dump display the file path?

Tags:

php

var-dump

I'm having some problems with var_dump.

This is my code:

$rezultat = 5 < 2;
$rezultat1 = 5 > 2;
var_dump($rezultat);
echo $rezultat1;

And this outputs:

C:\wamp\www\djole-php\test.php:5:boolean false 1

As you can see, var_dump displays the whole path before the result instead of just "boolean false".

Can I make it just show the result without the path?

like image 530
Karadjordje Avatar asked Oct 21 '16 19:10

Karadjordje


1 Answers

This is because of xdebug overloading var_dump. If you edit your php.ini and add

xdebug.overload_var_dump=1

You will no longer get the filename and line number with var_dump. The default setting is 2, which includes the filename and line number with the variable info. A setting of 0 will disable the xdebug override altogether.

As far as how to update php.ini, there are a lot of xdebug settings that probably aren't defined there, and xdebug will just use their default values. So if it's not there, you can add it and it will override the default. If it is there, just change its value.

Where you put it doesn't matter too much. If you see any other xdebug settings, you can put it with them. If not, at the end should be fine.


If you just want to see the value of the variable without any other information, consider using var_export instead of var_dump.

like image 158
Don't Panic Avatar answered Oct 08 '22 04:10

Don't Panic