Home > php教程 > PHP源码 > php closedir 函数

php closedir 函数

WBOY
Release: 2016-06-08 17:28:59
Original
1577 people have browsed it
<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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template