Xdebug 奇怪的 __DIR__ 常量 [英] Xdebug weird __DIR__ constant
本文介绍了Xdebug 奇怪的 __DIR__ 常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个加载 YAML 文件的 PHP CLI 应用程序.在 Xdebug 会话中尝试执行此操作时:
I am writing an PHP CLI app which loads YAML files. When trying to do this within an Xdebug session:
if (file_exists(__DIR__ . '/../../foo/bar')
{
/* ... */
}
__DIR__
始终是 xdebug:
这将始终导致 file_exists()
的 false
.
__DIR__
allways is xdebug:
which will allways lead to false
from file_exists()
.
有什么解决办法吗?
推荐答案
Set $dir = __DIR__;
并使用 if (file_exists($dir . '/../../foo/bar')
.它会这样工作.
Set $dir = __DIR__;
and use if (file_exists($dir . '/../../foo/bar')
. It will work like that.
这篇关于Xdebug 奇怪的 __DIR__ 常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文