# PHP 函数:readdir()

**URL:** <https://www.isharkfly.com/t/php-readdir/3511>\
**Category:** PHP\
**Created:** [October 27, 2012, 4:11am UTC](https://www.isharkfly.com/t/php-readdir/3511 "2012-10-27T04:11:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [October 27, 2012, 4:11am UTC](https://www.isharkfly.com/t/php-readdir/3511/1 "2012-10-27T04:11:09Z")

</div>

读取目录 handle。

语法: string readdir(int dir\_handle);

返回值: 字符串

函数种类: 文件存取

内容说明  
本函数用来读取目录。返回目录中的文件名称，读取不照任何特殊的顺序。

使用范例  
本例列出目前目录的所有文件

\<?php $handle=opendir('.'); echo "目录 handle: $handle\n"; echo "文件:\n"; while ($file = readdir($handle)) { echo "$file\n"; } closedir($handle); ?\>
