小白教程
所有教程
关于
Search
172.70.126.42
172.70.126.42
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func directory dir”的源代码
本页内容
上一节:
Func_directory_closedir
下一节:
Func_directory_getcwd
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:dir()}}[[Category:PHP Directory 文件目录参考手册|4]] = PHP dir() 函数 = [[:Category:PHP Directory 文件目录参考手册]] 使用 dir() 函数: <sample title="" desc="" lang="php" hererun="1"> <?php $d = dir(getcwd()); echo "Handle: " . $d->handle . "<br>"; echo "Path: " . $d->path . "<br>"; while (($file = $d->read()) !== false){ echo "filename: " . $file . "<br>"; } $d->close(); ?> </sample> 结果: <sample title="" desc="" lang="php" hererun="1"> Handle: Resource id #2 Path: /etc/php filename: . filename: .. filename: ajax.gif filename: books.xml filename: cdcatalog.xml filename: cd_catalog.xml filename: default.html filename: demo_array.html filename: demo_array.htm ... ... ... </sample> == 定义和用法 == dir() 函数返回 Directory 类的实例。该函数用于读取一个目录,包含如下: * 给定的要打开的目录 * dir() 的 handle 和 path 两个属性是可用的 * handle 和 path 属性有三个方法:read()、rewind() 和 close() == 语法 == <pre> dir(directory,context);</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | directory | 必需。规定要打开的目录。 |- | context | 可选。 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 返回 Directory 类的实例。失败则返回 FALSE。 |- | PHP 版本: | 4.0+ |} [[:Category:PHP Directory 文件目录参考手册]]
返回至“
Func directory dir
”。
上一节:
Func_directory_closedir
下一节:
Func_directory_getcwd