我正在尝试使用 require_once
在 Mac OSX 狮子上本地使用相对路径:
require_once('../../folder/file.php5');
并且每次都会抛出错误:
PHP Warning: require_once(../../folder/file.php5): failed to open stream:
No such file or directory in - on line 6 PHP Fatal error: require_once():
Failed opening required '../../folder/file.php5' (include_path='.:') in - on line 6
文件和文件夹结构与Web主机完全相同,并且可以在那里工作而没有问题。
require_once('../../folder/file.php5');
另一个奇怪的事情是我只能通过我的代码编辑器 CODA 预览来获得 PHP 错误。如果我在浏览器中加载相同的 URL,它会输出 PHP5 文件的正文,就像您在纯文本中看到的那样。
什么原因导致上述故障?
错误输出显示您的include_path
.:
。我怀疑这是问题所在,但是您是否尝试过将其设置为仅.
?还是在冒号之后放另一条路?(等,.:/some/other/path
)