“Func directory closedir”的版本间差异
本页内容
(创建页面,内容为“{{DISPLAYTITLE:closedir()}}3 = PHP closedir() 函数 = PHP Directory 参考手册 打开一个目录,读取它的内容,然后关闭: <sample title="" desc="" lang="php" hererun="1">example_start <?php $dir = "/images/"; // Open a directory, and read its contents if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ echo "filename:" . $file . "<br>";…”) |
(没有差异)
|
2022年8月17日 (三) 22:14的最新版本
PHP closedir() 函数
Category:PHP Directory 文件目录参考手册
打开一个目录,读取它的内容,然后关闭:
示例
<?php
$dir = "/images/";
// Open a directory, and read its contents
if
(is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
echo "filename:" . $file . "<br>";
}
closedir($dh);
}
}
?>
结果:
示例
filename: cat.gif
filename: dog.gif
filename: horse.gif
定义和用法
closedir() 函数关闭目录句柄。
语法
closedir(dir_handle);
参数 | 描述 |
---|---|
dir_handle | 可选。指定之前由 opendir() 打开的目录句柄资源。如果该参数未指定,则使用最后一个由 opendir() 打开的链接。 |
技术细节
返回值: | - |
PHP 版本: | 4.0+ |