PHP 警告:无法打开流:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17947109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Warning: failed to open stream: no such file or directory
提问by user1866880
I am working on local server, but I am having problem including files, even with full path given. eg, I have a file /home/[user]/public_html/vt/test.php
like this:
我在本地服务器上工作,但我在包含文件时遇到问题,即使给定了完整路径。例如,我有一个/home/[user]/public_html/vt/test.php
这样的文件:
<?php
include_once('/home/<user>/public_html/vt/Menu.php');
print "included_once called.\n";
?>
I got error in error_log
:
我有以下错误error_log
:
failed to open stream: No such file or directory
/home/[user]/public_html/vt/Menu.phpexists, and access right is:
/home/[user]/public_html/vt/Menu.php存在,访问权限为:
-rwxr-xr-x. 1 <user> apache 3906 Jul 5 08:43 <full/path/of/the/file>
The local documentRoot folder is set to (recursively):
本地 documentRoot 文件夹设置为(递归):
drwxr-xr-x. 4 <user> apache 4096 Jul 26 14:06 public_html
So what is wrong?
那么有什么问题呢?
回答by bitWorking
回答by krishna
this will help you
这会帮助你
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include "$root/inc/include1.php";