PHP 遍历XP文件夹下所有文件


  本文标签:PHP,遍历,文件夹

复制代码 代码如下:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
//PHP遍历文件夹下所有文件
$handle=opendir(C:\\); //我要遍历C盘的文件
echo "目录 handle: $handle <br/>";
echo "文件: <br/>";
while ($file =readdir($handle)) {
$file=iconv(GB2312,UTF-8,$file);//将XP的gbk编码转成UTF8
echo "$file <br/>"; //输出文件名
}
closedir($handle);
?>