file_exists
不工作..也尝试过realpath
..同样的问题
首先检查文件是否存在..file_exists
返回false,但仍会加载文件
chdir(__DIR__.'/../..');
$file = 'frontend.php';
echo "$file\n";
if(file_exists($file)){
echo "File found\n";
}
else{
echo "File not found\n";
}
require $file;
frontend.php
File not found
Contents of frontend.php
如php.net/file_exists所说,file_exists()函数需要:
文件或目录的路径。
因此,请尝试在目录路径前添加:
if (file_exists(dirname(__FILE__) . $file)) {
echo "File found\n";
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句