$num=0; //用来记录目录下的文件个数
$dirname='./'; //要遍历的目录名字
$dir_handle=opendir($dirname);
echo '
echo '
目录'.$dirname.'的内容
';echo '
';echo '
序号名称大小类型修改时间';while($file=readdir($dir_handle))
{
if($file!="."&&$file!="..")
{
$dirFile=$dirname."/".$file;
if($num++%2==0) //隔行换色
$bgcolor="#ffffff";
else
$bgcolor="#cccccc";
echo '
';echo '
'.$num.'';//序号echo '
'.$file.''; //名称 链接echo '
'.filesize($dirFile).'';//大小echo '
'.filetype($dirFile).'';//类型echo '
'.date("Y/n/t",filemtime($dirFile)).'';//修改时间echo '
';}
}
echo '
';closedir($dir_handle);
echo '在'.$dirname.'目录下的子目录和文件共有'.$num.'个';
?>