# The DirectoryIterator class

(PHP 5, PHP 7, PHP 8)

## 简介

The DirectoryIterator class provides a simple interface for viewing the contents of filesystem directories.

## 类摘要

class DirectoryIterator extends SplFileInfo implements SeekableIterator {
/* 方法 */
public function __construct(string `$directory`)
public function current(): mixed
public function getBasename(string `$suffix` = ""): string
public function getExtension(): string
public function getFilename(): string
public function isDot(): bool
public function key(): mixed
public function next(): void
public function rewind(): void
public function seek(int `$offset`): void
public function __toString(): string
public function valid(): bool
/* 继承的方法 */
public function SplFileInfo::getATime(): int|false
public function SplFileInfo::getBasename(string `$suffix` = ""): string
public function SplFileInfo::getCTime(): int|false
public function SplFileInfo::getExtension(): string
public function SplFileInfo::getFileInfo(?string `$class` = `null`): SplFileInfo
public function SplFileInfo::getFilename(): string
public function SplFileInfo::getGroup(): int|false
public function SplFileInfo::getInode(): int|false
public function SplFileInfo::getLinkTarget(): string|false
public function SplFileInfo::getMTime(): int|false
public function SplFileInfo::getOwner(): int|false
public function SplFileInfo::getPath(): string
public function SplFileInfo::getPathInfo(?string `$class` = `null`): ?SplFileInfo
public function SplFileInfo::getPathname(): string
public function SplFileInfo::getPerms(): int|false
public function SplFileInfo::getRealPath(): string|false
public function SplFileInfo::getSize(): int|false
public function SplFileInfo::getType(): string|false
public function SplFileInfo::isDir(): bool
public function SplFileInfo::isExecutable(): bool
public function SplFileInfo::isFile(): bool
public function SplFileInfo::isLink(): bool
public function SplFileInfo::isReadable(): bool
public function SplFileInfo::isWritable(): bool
public function SplFileInfo::openFile(string `$mode` = "r", bool `$useIncludePath` = `false`, ?resource `$context` = `null`): SplFileObject
public function SplFileInfo::setFileClass(string `$class` = `SplFileObject::class`): void
public function SplFileInfo::setInfoClass(string `$class` = `SplFileInfo::class`): void
public function SplFileInfo::__toString(): string
}

## 目录

- DirectoryIterator::__construct — Constructs a new directory iterator from a path
- DirectoryIterator::current — Return the current DirectoryIterator item
- DirectoryIterator::getBasename — Get base name of current DirectoryIterator item
- DirectoryIterator::getExtension — Gets the file extension
- DirectoryIterator::getFilename — Return file name of current DirectoryIterator item
- DirectoryIterator::isDot — Determine if current DirectoryIterator item is '.' or '..'
- DirectoryIterator::key — Return the key for the current DirectoryIterator item
- DirectoryIterator::next — Move forward to next DirectoryIterator item
- DirectoryIterator::rewind — Rewind the DirectoryIterator back to the start
- DirectoryIterator::seek — Seek to a DirectoryIterator item
- DirectoryIterator::__toString — Get file name as a string
- DirectoryIterator::valid — Check whether current DirectoryIterator position is a valid file

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open