php遍历中文目录出现问题
程序员文章站
2022-04-25 08:49:49
...
php
$path= iconv ( "UTF-8", "GBK", $path);
if(!is_dir ( $path )){
echo "你输入的路径不是目录,请检查后重新输入!";
}
$file = opendir ( $path );
while ( $flist = readdir ( $file ) ) {
// 去除.和..
if ($flist == '.' || $flist == '..')
continue;
$filename = $path . '/' . $flist;
$name = iconv ( "GBk", "UTF-8", $filename );
if (is_dir ( $filename )) {
$this->readDir ( $filename );
} else {
$filename = iconv ( "GBk", "UTF-8", $filename );
echo $filename ;
}
}
在win7中可以遍历中文目录,在windows server 2003 输出的是你输入的路径不是目录,请检查后重新输入!
是什么原因