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 디렉토리 참조