close
<?php
$dir = "/etc/php5/";
// Open a known directory, read directory into variable and then close
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$directory = readdir($dh);
closedir($dh);
}
}
?>
例子
<?php
//打開images目錄
$dir = opendir("images");
//列出images 目錄中的文件
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
?>
輸出:
filename: .
filename: ..
filename: cat.gif
filename: dog.gif
filename: food
filename: horse.gif
全站熱搜
留言列表