PHP closedir() Funktion
Beispiel
Öffnen Sie ein Verzeichnis, lesen Sie seinen Inhalt und schließen Sie es:
<?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);
}
}
?>
Ergebnis:
filename: cat.gif
filename: dog.gif
filename: horse.gif
Definition und Verwendung
Die closedir()-Funktion schließt ein Verzeichnis-Handle.
Syntax
closedir(dir)
Parameterwerte
Parameter | Description |
---|---|
dir | Optional. Specifies the directory handle resource previously opened with opendir(). If this parameter is not specified, the last link opened by opendir() is assumed |
Technische Details
Rückgabewert: | - |
---|---|
PHP-Version: | 4.0+ |
❮ PHP-Verzeichnisreferenz