Home >Backend Development >PHP Tutorial >php code to list all files in a directory
This article introduces how to use php code to list all files in the directory. Friends in need can refer to it.
The code is as follows: <?php /** * 列出目录中所有文件 * edit bbs.it-home.org */ $current_dir = 'F:/www/'; $dir = opendir($current_dir); echo "direcotry list:<ul>"; while(false !== ($file=readdir($dir))){ if($file != "." && $file != ".."){ echo "<li>$file</li>"; } } echo "</ul>"; closedir($dir); ?> The above code was tested under windows. If it is the same drive letter as the web, just write: $current_dir='/www/';. |