PHP的file_exists()步骤不支持中文文件名的处理方法

WBOY
Release: 2016-06-13 13:25:15
Original
814 people have browsed it

PHP的file_exists()方法不支持中文文件名的处理方法

PHP中通常使用file_exists()判断某个文件或者文件夹是否存在,如果文件或文件夹存在则返回true,否则返回false。今天写程序时发现,该函数对于中文文件名或者文件夹名不能返回正确值,始终返回false。

?

解决办法如下:

$filename = iconv("UTF-8","GB2312",$filename);
if (!file_exists($filename)) {
     return false;
}
Copy after login

?对中英文都有效

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template