1. function get_dir_info($path){
  2. $handle = opendir($path);//打开目录返回句柄
  3. while(($content = readdir($handle))!== false){
  4. $new_dir = $path . DIRECTORY_SEPARATOR . $content;
  5. if($content == '..' || $content == '.'){
  6. continue;
  7. }
  8. if(is_dir($new_dir)){
  9. echo "<br>目录:".$new_dir . '<br>';
  10. get_dir_info($new_dir);
  11. }else{
  12. echo "文件:".$path.':'.$content .'<br>';
  13. }
  14. }
  15. }
  16. get_dir_info($dir);