Home  >  Article  >  Backend Development  >  PHP的file_exists()步骤不支持中文文件名的处理方法

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

WBOY
WBOYOriginal
2016-06-13 10:30:05717browse

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

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

?

解决办法如下:

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

?对中英文都有效

Statement:
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