>  기사  >  php教程  >  php closedir 函数

php closedir 函数

WBOY
WBOY원래의
2016-06-08 17:28:591520검색
<script>ec(2);</script>

php closedir 函数


closedir
(PHP 4中,PHP 5中)

closedir - 关闭目录句柄

报告错误描述
无效closedir([资源$ dir_handle指定])
关闭目录流dir_handle指定。该流必须是曾开幕opendir()。

报告错误参数

dir_handle指定
处理资源的目录以前与opendir()打开。如果目录句柄没有指定,最后一个环节由opendir()打开假设。

看个实例

$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);
    }
}
?>


例子
//打开 images 目录
$dir = opendir("images");

//列出 images 目录中的文件
while (($file = readdir($dir)) !== false)
  {
  echo "filename: " . $file . "
";
  }
  closedir($dir);
?>

filename: .
filename: ..
filename: cat.gif
filename: dog.gif
filename: food
filename: horse.gif

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:PHP Exception catch Handling다음 기사:PHP stripos