<?php header('Content-Type: text/html; charset=utf-8'); /** * @param 目錄地址 */ function readDirs($path) { $dir_handle = openDir($path); while(false !== $file=readDir($dir_handle)) { if ($file=='.' || $file=='..') continue; //輸出該文件 echo $file, '<br>'; //判斷當前是否為目錄 if(is_dir($path . '/' . $file)) { //是目錄 readDirs($path . '/' . $file); } } closeDir($dir_handle); } // $path = './'; // readDirs($path);