PHP closedir()ฟังก์ชั่น
ตัวอย่าง
เปิดไดเร็กทอรี อ่านเนื้อหา จากนั้นปิด:
<?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);
}
}
?>
ผลลัพธ์:
filename: cat.gif
filename: dog.gif
filename: horse.gif
ความหมายและการใช้งาน
ฟังก์ชัน closedir() ปิดตัวจัดการไดเร็กทอรี
ไวยากรณ์
closedir(dir)
ค่าพารามิเตอร์
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 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | - |
---|---|
รุ่น PHP: | 4.0+ |
❮ การอ้างอิงไดเรกทอรี PHP