closedir in PHP

Syntax of closedir in PHP

void closedir([int handle])

Closes the directory stream referenced by handle. See opendir() for more information on directory streams. If handle is not specified, the most recently opened directory stream is closed.

Example of closedir

<?php
$dir = "/etc/php5/";

// Open a known directory, read directory into variable and then close
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        $directory = readdir($dh);
        closedir($dh);
    }
}
?>

Leave a Comment