English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Directory Reference Manual
The closedir() function is used to close directory handles
void closedir ( resource $dir_handle );
It closes the directory stream indicated by dir_handle. The stream must have been previously opened by opendir().
Number | Parameters and Description |
---|---|
1 | dir_handle (required) The resource handle of the directory, previously opened by opendir(). If the directory handle is not specified, it is assumed to be the last handle opened by opendir(). |
Returns TRUE on success, FALSE on failure.
The following is the usage of this function: open a directory, read its contents, and then close it:
<?php $dir = opendir("/var/www/images"); while (($file = readdir($dir)) !== false) { echo "filename: " . $file . "<br />"; } closedir($dir); ?>
Output result:
filename: . filename: .. filename: logo.gif filename: mohd.gif