首页 > 开发 > PHP > 正文

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

2024-05-04 22:11:43
字体:
来源:转载
供稿:网友
代码如下:
<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);
?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表