- php教程首页
- php文件操作
php递归删除目录所有文件
•php文件操作•阅读 332 - <meta http-equiv="content-type" content="text/html; charset=gb2312">
- <?php
- function tree($directory)
- {
- $mydir=dir($directory);
- echo "<ul> ";
- while($file=$mydir->read()){
- if((is_dir("$directory/$file")) and ($file!=".") and ($file!=".."))
- {echo "<li><font color="#ff00cc"><b>$file</b></font></li> ";
- tree("$directory/$file");
- }
- else{//开源代码phpfensi.com
- $a = explode('.',$file);
- if($a[1] == 'html' || $a[1] == 'htm')
- {
- //unlink($file);
- echo "<li>$file</li> ";
- }
- }
- }
- echo "</ul> ";
- $mydir->close();
- }
- //开始运行
- echo "<h2>目录为粉红色</h2><br> ";
- tree("./");
- ?>