표준 PHP 라이브러리(SPL) DirectoryIterator::__construct
(PHP 5, PHP 7, PHP 8)
DirectoryIterator::__construct — 경로에서 새 디렉토리 반복자를 생성합니다.
설명
public DirectoryIterator::__construct(string $directory
)
경로에서 새 디렉토리 반복자를 생성합니다.
매개변수
directory
- 트래버스할 디렉터리의 경로입니다.
오류/예외
directory
가 존재하지 않으면 UnexpectedValueException을 던집니다.
directory
가 빈 문자열이면 ValueError를 던집니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | 이제 directory 가 빈 문자열이면 ValueError가 발생합니다. 이전에는 RuntimeException이 발생했습니다. |
Examples
예제 #1 DirectoryIterator::__construct() 예제
이 예는 스크립트가 포함된 디렉토리의 내용을 나열합니다.
<?php
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
var_dump($fileinfo->getFilename());
}
}
?>