php closedir 函数
php closedir 函数
closedir
(PHP 4中,PHP 5中)
closedir - 关闭目录句柄
报告错误描述
无效closedir([资源$ dir_handle指定])
关闭目录流dir_handle指定。该流必须是曾开幕opendir()。
报告错误参数
dir_handle指定
处理资源的目录以前与opendir()打开。如果目录句柄没有指定,最后一个环节由opendir()打开假设。
看个实例
<?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
本文地址:http://www.phprm.com/code/closedir.html
转载随意,但请附上文章地址:-)