当前位置:Gxlcms > PHP教程 > PHP 遍历XP文件夹下所有文件

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

时间:2021-07-01 10:21:17 帮助过:8人阅读

代码如下:
<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);
?>

人气教程排行