遍历文件夹下的所有文件和文件夹-php

function get_dir_info($path){
$handle = opendir($path);//打开目录返回句柄
while(($content = readdir($handle))!== false){
$new_dir = $path . DIRECTORY_SEPARATOR . $content;
if($content == '..' || $content == '.'){
continue;
}
if(is_dir($new_dir)){
echo "<br>目录:".$new_dir . '<br>';
get_dir_info($new_dir);
}else{
echo "文件:".$path.':'.$content .'<br>';
}
}
}
get_dir_info($dir);
posted @ 2018-04-02 11:51  刹那风华——  阅读(166)  评论(0编辑  收藏  举报