|
发表于 2005 年 9 月 1 日 20:56:07
|
显示全部楼层
<?
$dirURL = '.';
$nIndInc = 4;
ListDir($dirURL);
function ListDir( $dirURL, $nIndent=0 ) {
global $nIndInc;
if ($handle = opendir($dirURL)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$wholeFileName = $dirURL."/".$file;
if (is_dir($wholeFileName)) {
PrintFileName($file, $nIndent);
ListDir($wholeFileName,$nIndent+$nIndInc);
} else if (is_file($wholeFileName)) {
PrintFileName($file, $nIndent);
} else {
PrintErr($file);
}
}
}
}
}
function PrintFileName($file, $nIndent) {
for( $i=0; $i<$nIndent; $i++ ) echo " ";
echo $file;
echo "
";
}
function PrintErr($file) {
echo "error : {$file}! Maybe the program is something wrong!
";
}
?> |
|