瀏覽目錄文件
<--瀏覽當前目錄文件,並在網頁上鏈接顯示,php源程序如下,本程序在WINDOWS98測試成功,源程序如下:
-->
<html>
<body>
<?php
$handle
=opendir("."); //取當前目錄句柄
echo "目錄 handle:$handle
"
;
$dirn=dirname("."); //取當前目錄名
echo "目錄名是:$dirn";
echo 
"<br>";
echo 
"文件:
"
;
echo 
"<br>";
while(
$file=readdir($handle))
{
$files=filesize($file);  //取文件大小
if (is_file($file))      //如果是文件的話就鏈接顯示
{
  echo 
"<a href=$file>文件名:$file
大小:$files
類型:$filet
</a><br>"
;
}
else
{
  echo 
"目錄名:$file
大小:$files
</a><br>"
;
}
}
closedir($handle); //關閉目錄句柄
?>
</body>
</html>