如果你想列出目录下的所有文件,使用以下代码即可:
1 function listDirFiles($DirPath){ 2 3 if($dir = opendir($DirPath)){ 4 5 while(($file = readdir($dir))!== false){ 6 7 if(!is_dir($DirPath.$file)) 8 9 { 10 11 echo "filename: $file
"; 12 13 } 14 15 } 16 17 } 18 19 } 20 21 //使用方法如下 22 23 listDirFiles('home/some_folder/');