While debugging a PHP script using the "Listen for XDebug" in VS code(PHP Debug by Felix Becker extension), I found that the __DIR__ and __File__
which are supposed to return the directory and the filename of the current running script are being overridden by Xdebug:
__DIR__ contains
"xdebug:"
__FILE__ contains
"xdebug://debug-eval"
However, if I assign the values to local variables, it works as expected.
$dir = __DIR__; // $dir holds the correct path, instead of "xdebug:"
This issue was encountered here Xdebug weird __DIR__ constant.
However the post is old, and is missing resourceful explanation for the unexpected behavior.
Your help is appreciated.