简体   繁体   English

PHP警告:无法打开流:没有这样的文件或目录

[英]PHP Warning: failed to open stream: no such file or directory

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.php exists, 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? 那有什么不对?

try something like that: ( DIR is a magic constant which contains the directory of the current file) 尝试类似的东西:( DIR是一个包含当前文件目录的魔术常量)

include_once dirname(__FILE__).'/Menu.php';

// PHP >= 5.3
include_once __DIR__.'/Menu.php';

this will help you 这会对你有所帮助

$root = realpath($_SERVER["DOCUMENT_ROOT"]);

include "$root/inc/include1.php";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 php中的警告:无法打开流:没有这样的文件/目录 - warning in php:Failed to open stream:no such file /directory in PHP警告:无法打开流:没有此类文件或目录,文件路径错误 - PHP Warning: failed to open stream: No such file or directory, File Path Errors 警告:包括(dbconn.php):无法打开流:没有这样的文件或目录 - Warning: include(dbconn.php): failed to open stream: No such file or directory 断断续续-PHP警告:包括无法打开流:没有此类文件或目录 - intermittent - PHP Warning: include failed to open stream: No such file or directory PHP警告:require_once:无法打开流:在目录中没有这样的文件或目录 - PHP Warning: require_once: failed to open stream: No such file or directory in PHP 警告:require_once 无法打开流:中没有这样的文件或目录 - PHP Warning: require_once failed to open stream: No such file or directory in 警告:include(PHPExcel.php):无法打开流:没有这样的文件或目录 - Warning: include(PHPExcel.php): failed to open stream: No such file or directory 警告:未知:无法打开 stream:第 0 行未知中没有此类文件或目录 (php) - Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 (php) PHP 警告:file_put_contents() 未能打开 stream:是一个目录 - PHP Warning: file_put_contents() failed to open stream: Is a directory in 警告:复制(..):无法打开流:中没有这样的文件或目录 - Warning: copy(..): failed to open stream: No such file or directory in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM