closedir

(PHP 4, PHP 5, PHP 7)

closedir디렉토리 핸들을 닫습니다

설명

void closedir ([ resource $dir_handle ] )

dir_handle가 지시하는 디렉토리 스트림을 닫습니다. 스트림은 opendir()로 열려 있는 것이여야 합니다.

인수

dir_handle

opendir()로 열린 디렉토리 핸들 resource. 디렉토리 핸들이 지정되지 않으면, opendir()로 열린 마지막 연결을 할당합니다.

예제

Example #1 closedir() 예제

<?php
// 디렉토리를 열고, 읽어서 변수로 넣고 닫습니다.
if (is_dir($dir)) {
    if (
$dh opendir($dir)) {
        
$directory readdir($dh);
        
closedir($dh);
    }
}
?>

add a note add a note

User Contributed Notes 1 note

up
-32
foo at bar dot com
23 years ago
About deleting a directory after doing a readdir/closedir on it... I'm not sure if this is the solution, but you could try to chdir("/"); before the rmdir to make absolutely sure you aren't standing in the directory (i.e trying to pull out the rug from under yourself).
To Top