Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 PHP中opendir的用法

PHP中opendir的用法

发布时间:2020-11-14   编辑:www.jquerycn.cn
jquery中文网为您提供PHP中opendir的用法等资源,欢迎您收藏本站,我们将为您提供最新的PHP中opendir的用法资源

PHP opendir() 函数

实例

<?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

定义和用法

  opendir() 函数打开目录句柄。

语法

opendir(path,context);
参数描述
path必需。规定要打开的目录路径。
context可选。规定目录句柄的环境。context 是可修改目录流的行为的一套选项。

技术细节

返回值:成功则返回目录句柄资源。失败则返回 FALSE。如果路径不是合法目录,或者由于许可限制或文件系统错误导致的目录不能打开,则抛出 E_WARNING 级别的错误。您可以通过在函数名称前添加 '@' 来隐藏 opendir() 的错误输出。
PHP 版本:4.0
PHP 更新日志:PHP 5.0:path 参数支持 ftp:// URL 封装协议。

以上就是PHP中opendir的用法的详细内容,更多请关注jquery中文网其它相关文章!

  • 本文原创发布jQuery中文网,转载请注明出处,感谢您的尊重!
  • 您可能感兴趣的文章:
    PHP遍历某文件夹下全部文件方法示例
    php的opendir是什么意思?
    PHP中opendir的用法
    PHP rewinddir() 函数
    PHP opendir() 函数
    PHP readdir() 函数
    PHP closedir() 函数
    php列出指定目录所有子文件夹与文件实例
    PHP删除非空目录的三个函数
    PHP glob函数遍历目录/文件夹方法介绍

    [关闭]