English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Directory Reference Manual
The dir() function returns an instance of the Directory class
dirhandle bool dir ( string $directory )
The dir() function opens a directory handle and returns an object. This object contains three methods, namely read(), rewind(), and close().
Number | Parameters and descriptions |
---|---|
1 | directory(必需) The directory to be opened. |
If successful, returns an instance of the Directory class, returns NULL if the parameter is incorrect, and returns FALSE for other error conditions.
The following is the usage of the dir() function:
<?php $d = dir("/var/www/"); echo "Handle: " . $d->handle . "\n"; echo "Path: " . $d->path . "\n"; while (false !== ($entry = $d->read())) { echo $entry."\n"; } $d->close(); ?>
Output result:
Handle: Resource id #5 Path: /var/www/ .. cgi-bin html .