Rainie999 发表于 2017-3-26 13:20:13

PHP打印目录结构

  


<?php
function displayDir($path)
{
echo "<table border=\"1\">";
echo "<tr>";
echo "<td>文件名</td>";
echo "<td>文件大小</td>";
echo "<td>文件类型</td>";
echo "<td>修改时间</td>";
echo "</tr>";
$dirHandle=opendir($path);
while( $file = readdir($dirHandle) )
{
echo "<tr>";
echo "<td>".$file."</td>";
$filepath=$path."/".$file;   //文件具体路径
echo "<td>".filesize($filepath)."</td>";
echo "<td>".filetype($filepath)."</td>";
echo "<td>".date("Y年n月t日",filemtime($filepath))."</td>";
echo "</tr>";
}
closedir($dirHandle);
echo "</table>";
}
?>
 
页: [1]
查看完整版本: PHP打印目录结构