文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>遍历目录操作

遍历目录操作

时间:2007-11-02  来源:phpoop


?php
//遍历目录操作
$handle = @opendir("D:\\usr\\webroot\\test\\file");
//遍历目录,方法一
if ($handle) {
    echo "目录下文件:\n";
    while (false !==($file = readdir($handle))){
        echo "$file \n";
    }
} else {
    echo "Error!";
}
//方法二 Directory类遍历目录
/*
Directory类是内建类,包含2个属性和3个方法
class Directory {
  string $path
  resourse $handle
  string read()
  void rewind()
  void close()
}
*/
$dir = dir("D:\\usr\\webroot\\test");
echo "Handle:"."$dir->handle"."\n";
echo "Path:"."$dir->path"."\n";
while (false !==($file = $dir->read())){
    echo "$file \n";
}
$dir->close;
?>


相关阅读 更多 +
排行榜 更多 +
hacked

hacked

休闲益智 下载
佩科佩科的寿司手机版

佩科佩科的寿司手机版

休闲益智 下载
钓鱼好友

钓鱼好友

休闲益智 下载