小白教程
所有教程
关于
Search
172.70.126.232
172.70.126.232
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func directory opendir”的源代码
本页内容
上一节:
Func_directory_getcwd
下一节:
Func_directory_readdir
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:opendir()}}[[Category:PHP Directory 文件目录参考手册|6]] = PHP opendir() 函数 = [[:Category:PHP Directory 文件目录参考手册]] 打开一个目录,读取它的内容,然后关闭: <sample title="" desc="" lang="php" hererun="1"> <?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); } } ?> </sample> 结果: <sample title="" desc="" lang="php" hererun="1"> filename: cat.gif filename: dog.gif filename: horse.gif </sample> == 定义和用法 == opendir() 函数打开目录句柄。 == 语法 == <pre> opendir(path,context);</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | path | 必需。规定要打开的目录路径。 |- | context | 可选。规定目录句柄的环境。context 是可修改目录流的行为的一套选项。 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 成功则返回目录句柄资源。失败则返回 FALSE。如果路径不是合法目录,或者由于许可限制或文件系统错误导致的目录不能打开,则抛出 E_WARNING 级别的错误。您可以通过在函数名称前添加 '@' 来隐藏 opendir() 的错误输出。 |- | PHP 版本: | 4.0+ |- | PHP 更新日志: | PHP 5.0:path 参数支持 '''ftp://''' URL 封装协议。 |} [[:Category:PHP Directory 文件目录参考手册]]
返回至“
Func directory opendir
”。
上一节:
Func_directory_getcwd
下一节:
Func_directory_readdir