Home > Article > Backend Development > The solution to the problem that file_exists does not support Chinese file names
This article introduces how to solve the problem that the file_exists() function does not support Chinese file names. Here is a method for your reference.
When using file_exists() to determine whether a file or folder exists, it returns true if the file or folder exists, otherwise it returns false. However, this function cannot return the correct value for Chinese file names or folder names, and always returns false. I thought of a solution and would like to share it. Code: <?php //解决file_exists不支持中文文件名的问题 $filename = iconv("UTF-8","GB2312",$filename); if (!file_exists($filename)) { return false; } //经过如上的转换,则对中英文就都可以支持了 ?> |