【发布时间】:2017-06-14 12:27:02
【问题描述】:
我通常使用 WAMP,但由于某种原因不得不切换到 XAMPP。
遇到了这个非常奇怪的问题。当我尝试使用 file_get_contents 读取文件时,我收到一条错误消息,指出文件/目录不存在,即使它确实存在。
即使像
这样简单的事情file_get_contents('x.txt');
抛出错误
Warning: file_get_contents(x.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\cryy\index.php on line 3
是的,我尝试过使用魔法常数
__DIR__
无济于事。
我使用的是 XAMPP 3.2.2 和 PHP 7.0.18,在 Windows 10 上运行。
希望有人能帮我解决这个问题。
【问题讨论】:
-
您的文件在哪里?执行此代码的文件在哪里?
-
尝试一次,提供您要读取的文件的完整路径
-
你的代码在
C:\xampp\htdocs\cryy\index.php所以文件也在`C:\xampp\htdocs\cryy` RIGHT??? -
@RiggsFolly 是的
标签: php apache xampp file-get-contents