方法1:据官方手册上描述若php的safe mode相关的设置过于苛刻,就会出现这样的情形:尽管文件真实存在也被误报,认为文件不存在。
由于服务器端的php.ini我们无法操纵,当用ini_set()也关闭不了safe mode模式,我们只有退而求其次,找一个更可靠、安全的检测方法来检测文件是否存在。我们可以借助 $_server['document_root'] 来加以实现。$_server['document_root'] 返回的是网站的根目录,该目录的最后一个子目录不包含目录标志符号“/”,如:
d:/www/htdocs
有了根目录,再加上需要检测的文件的路径,我们将得到一个绝对的路径,php就可以顺利使用file_exists()函数对之进行检测。上述代码我们只需要更改第一行为(注意,我们在config.php之前加上了符号“/”):
$file=$_server['document_root']."/config.php";
如此,代码的执行就很可信,不会出现预期以外的结果。
以上方法同样适用于目录(is_dir())或文件(is_file())的相关检测函数,能够检测出被安全保护的目录或文件是否存在。
最后顺便提一下:这类被php特殊设置所保护的文件在引用(include和require)时不必加上$_server['document_root']路径,因为,根据php说明文档,它们是允许引用的。
方法2:本人的情况是因为文件在windows和linux之间来回的移动。造成linux下文件和目录的访问权限被改变,导致出文件除拥有者外其他均无访问权限。使用chmod -r 755 xxx/* 解决了问题。
波比源码 » php file_exists无效解决办法
buy cialis on line Performing an ambulatory study was associated with increased age at the time of measurement p 0
The presence of human leukocyte antigen DR HLA DR and cluster of differentiation antigens CD was recently described Hageman et al cialis online india
There is not recommended to mix a solution of Furosemide in the same syringe with any other drugs propecia for sale in usa We may have arguments about efficacy and other matters, but, up to a couple of days ago, there didn t seem to be much disagreement about the starting point
Willy FtChESuYxC 5 29 2022 how much viagra cost Players hold out and teams cut players who are still under contract all the time