PHP generally uses file_exists () to determine whether a file or folder exists, and if the file or folder exists, returns True, False if it does not exist. Today, when implementing the file download function, it is found that the function cannot detect whether a file containing Chinese is present, and always returns false, in the case of a Web page using UTF8 encoding. The modification was long after the discovery because the full path was not encoded, and simply transcoding the file name was not enough.
The following code cannot detect whether a file containing Chinese is present, regardless of whether the file returns false:
Just to transcode the file name is not, this is the case I encountered, need to "path + file name" together to Transcode to
In fact, as long as the file path and file name from UTF8 encoding to GB2312 encoding, improved can be accurately judged:
The above describes the PHP file_exists function can not detect the file name containing the Chinese version of the solution, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.