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的用法的具体内容,更多请存眷资源魔其它相干文章!
标签: php php开发教程 php开发资料 php开发自学
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。