php递归删除目录所有文件
<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 {
$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("./");
?>文章网址:http://www.phprm.com/wenjian/fs4266.html
随意转载^^但请附上教程地址。