美文网首页
file_exists函数在PHP中不支持中文

file_exists函数在PHP中不支持中文

作者: 风度翩翩的程序猿 | 来源:发表于2023-06-08 13:42 被阅读0次
要解决file_exists函数在PHP中不支持中文的问题,可以采用以下2种方法:
$fileName = '中文文件名.txt';
$fileName = iconv('UTF-8', 'GBK', $fileName);
if (file_exists($fileName)) {
    //文件存在
} else {
    //文件不存在
}



2、
$fileName = '中文文件名.txt';
$fileName = mb_convert_encoding($fileName, 'GBK', 'UTF-8');
if (file_exists($fileName)) {
    //文件存在
} else {
    //文件不存在
}

相关文章

网友评论

      本文标题:file_exists函数在PHP中不支持中文

      本文链接:https://www.haomeiwen.com/subject/wccaedtx.html