简体   繁体   中英

How can I hide the file path in PHP / Xdebug "var_dump()"

I'm using PhpStorm with Xdebug.

When I use something like var_dump how can I hide this part shown in the browser?

在此处输入图像描述

The var_dump() function is used for inspecting and debugging the behavior of your code. What you're seeing is the Xdebug's version of it (you have Xdebug enabled and it overloads the default one), which prints out its location, too.

During the development it is quite helpful to see when and where exactly does the var_dump() function act out.

If you're worried that it's a security hole, unless you use var_dump() in production, it most probably is not, since it's only meant for the developer . If your users were to see this (eg. when you forget some var_dump() in production code) , then that would be bad.


If you're aware of this and you're still asking how to "hide the path" , you might probably want to disable the Xdebug's version of var_dump() . You can do that with this setting in your php.ini :

[XDebug]
xdebug.overload_var_dump = 0

Or really only hide the path with:

xdebug.overload_var_dump = 1

On Xdebug 3 I haven't found an official way to do it, but I've managed to hide the file name using the settings:

xdebug.filename_format = " "

(Note that the setting value is a white space and not an empty string)

ps If you rely on xdebug error handler, with this settings you might not see files names in the stack trace.

In Xdebug3 you need to turn correct debug mode

So, for example xdebug.mode=off will turn off file:line printing.

If someone are, after today, searching for a solution like me, I have solved this changing the Xdebug.mode to OFF in PHP settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM