当你想要包含一个PHP文件时,你应该使用哪一个?
if(file_exists($file) require "$file";
或
if(is_readable($file) require "$file";
发布于 2011-07-07 09:00:09
如果你要require
一个文件,那么错误检查就没有意义了。使用require
而不是include
的目的是在文件不存在时中止脚本的执行。
如果您不关心文件是否存在,只需使用include
即可。
发布于 2015-04-08 22:10:37
if (is_file($file) && is_readable($file))
因为对于目录,is_readable($file)
也可以是true
。
https://stackoverflow.com/questions/6604726
复制相似问题