Method 1: According to the official manual, if the Safe mode setting of the PHP tutorial is too harsh, this situation occurs: Even though the file is real, it is mistakenly reported that the file does not exist.
Because the server side of the php.ini we can not manipulate, when using Ini_set () also shut down the safe mode, we only go back and second, find a more reliable and safe detection method to detect the existence of files. We can do that with $_server[' document_root '. $_server[' Document_root ' returns the root directory of the Web site, and the last subdirectory of the directory does not contain the directory glyph "/", such as:
D:/www/htdocs
With the root directory, along with the path of the file that needs to be detected, we will get an absolute path, and PHP will be able to use the file_exists () function to detect it. The above code we only need to change the first behavior (note that we added the symbol "/" before config.php):
$file =$_server[' Document_root ']. " /config.php ";
Thus, the execution of the code is credible and does not result in unexpected results.
The above method is also applicable to the related detection function of the directory (Is_dir ()) or the file (Is_file ()), which can detect the existence of the secured directory or file.
Finally, incidentally: this type of file that is protected by PHP special settings does not have to be prefixed with the $_server[' document_root ' path when referencing (include and require) because, according to the PHP documentation, they are allowed to be referenced.
Method 2: I'm in the situation because the files move back and forth between Windows and Linux. Access to files and directories under Linux has been changed, resulting in no access to files other than the owner. Using the Chmod-r 755 xxx/* solves the problem.
http://www.bkjia.com/PHPjc/632318.html www.bkjia.com true http://www.bkjia.com/PHPjc/632318.html techarticle Method 1: According to the official manual, if the Safe mode setting of the PHP tutorial is too harsh, this situation occurs: Even though the file is real, it is mistakenly reported that the file does not exist. ...