PHP tertutup () Fungsi
Contoh
Buka direktori, baca isinya, lalu tutup:
<?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);
}
}
?>
Hasil:
filename: cat.gif
filename: dog.gif
filename: horse.gif
Definisi dan Penggunaan
Fungsi closedir() menutup pegangan direktori.
Sintaksis
closedir(dir)
Nilai Parameter
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 |
Detail Teknis
Nilai Kembali: | - |
---|---|
Versi PHP: | 4.0+ |
Referensi Direktori PHP