PHP file_exists with accent returns false

2019-02-21 19:10发布

I have two folders, Folder and Folderé. The second one could not be catch by PHP.

Here is my test:

<?php
        $dir = 'D:\wamp\www\test\data\Folder';
        var_dump(file_exists($dir)); // true

        $dir = 'D:\wamp\www\test\data\Folderé';
        var_dump(file_exists($dir)); // false
?>

How to fix it?

1条回答
叼着烟拽天下
2楼-- · 2019-02-21 20:00

This works like charm

<?php
$dir = 'D:\wamp\www\test\data\Folderé';
var_dump(file_exists((utf8_decode($dir))));
查看更多
登录 后发表回答