Col*_*lum 85
if(file_exists('file.php'))
include 'file.php';
Run Code Online (Sandbox Code Playgroud)
那应该做你想要的
尝试使用 file_exists()
if(file_exists($file)){
include $file;
}
Run Code Online (Sandbox Code Playgroud)
基于@ Select0r的答案,我最终使用了
if (file_exists(stream_resolve_include_path($file)))
include($file);
Run Code Online (Sandbox Code Playgroud)
即使您将此代码写入已从另一个目录中的文件中包含的文件中,此解决方案仍然有效.