如何在Scandir php的路径地址中使用UTF8字符 [英] how to use UTF8 character in path Address for Scandir php

查看:147
本文介绍了如何在Scandir php的路径地址中使用UTF8字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Scandir php的路径地址中使用UTF8字符

how to use UTF8 character in path Address for Scandir php

我的文件夹名称是: 61-تستتست

我在scandir和DirectoryIterator中出错.

i have error in scandir and DirectoryIterator.

将文件夹名称更改为 61 之后,可以解决我的问题,但需要全名.

after change folder name to 61 fix my problem but in need full name.

$folder = '61-تست تست';
        $path    = 'files/'.$folder;

print_r(scandir($path));

        foreach (new \DirectoryIterator($path) as $file) {
            if(!$file->isDir())
            {
                echo $file->getFilename() . "<br>";
            }
        }

错误:

    UnexpectedValueException

The system cannot find the file specified. (code: 2)

DirectoryIterator::__construct(D:/wamp64/www/project/web/files/61-تست تست,D:/wamp64/www/project/web/files/61-تست تست): The system cannot find the file specified. (code: 2)

推荐答案

ScanDir在PHP 5.6 LINUX 中表现良好,但仅通过FTP上传文件,而在PHP 5.6 Windows中不起作用,因此您在Windows中使用WFIO ext或升级到PHP 7.1

ScanDir good work in PHP 5.6 LINUX but upload files only with FTP and dont work in PHP 5.6 windows for fix this in windows you are use WFIO ext or Upgrade to PHP 7.1

这篇关于如何在Scandir php的路径地址中使用UTF8字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆