downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

closedir> <chroot
[edit] Last updated: Sat, 07 Jan 2012

view this page in

dir

(PHP 4, PHP 5)

dir디렉토리 클래스의 인스턴스를 반환합니다

설명

Directory {
string $Directory->path ;
resource $handle ;
string Directory::read ( void )
void Directory::rewind ( void )
void Directory::close ( void )
}

디렉토리를 읽는 모의-객체 기반 방법입니다. 주어진 directory를 엽니다. 열려진 디렉토리에 사용할 수 있는 두가지 프로퍼티가 존재합니다. handle 프로퍼티는 readdir(), rewinddir(), closedir() 등의 다른 디렉토리 함수에 사용할 수 있습니다. path 프로퍼티는 열려진 디렉토리의 경로가 지정됩니다. 세가지 메쏘드를 사용할 수 있습니다: read, rewind, close.

예제

Example #1 dir() 예제

dir::read()의 반환값은 아래 예제처럼 확인해야 하는 점에 주의하십시오. 반환값이 FALSE와 완전히 동일한지 (형까지 같게 - 자세한 정보는 비교 연산자를 참조) 확인하고 있습니다. 이렇게 하지 않으면, FALSE로 판단할 수 있는 이름을 가진 디렉토리 엔트리에서 루프가 멈춥니다.

<?php
$d 
dir("/etc/php5");
echo 
"Handle: " $d->handle "\n";
echo 
"Path: " $d->path "\n";
while (
false !== ($entry $d->read())) {
   echo 
$entry."\n";
}
$d->close();
?>

위 예제의 출력 예시:

Handle: Resource id #2
Path: /etc/php5
.
..
apache
cgi
cli

주의

Note:

read 메쏘드가 반환하는 디렉토리 엔트리의 순서는 시스템에 의존합니다.



add a note add a note User Contributed Notes dir
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites