<?php
function tree($dir)
{
$mydir = dir($dir);
echo "<ul>\n";
while ($file = $mydir->read()) {
if (is_dir("$dir/$file") AND $file != "." AND $file != "..") {
echo "<li><font color=\"#ff00cc\"><b>$file</b></font></li>";
tree("$dir/$file");
} else {
echo "<li>$file</li>\n";
}
}
echo "</ul>\n";
$mydir->close();
}
echo "<h2>目录为粉红色</h2><br>\n";
tree("e:/www");
function tree($dir)
{
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ((is_dir($dir . "/" . $file)) && $file != "." && $file != "..") {
echo "<b><font color='red'>文件名:</font></b>", $file, "<br><hr>";
tree($dir . "/" . $file . "/");
} else {
if ($file != "." && $file != "..") {
echo $file . "<br>";
}
}
}
closedir($dh);
}
}
}