# The FilesystemIterator class

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

## Introduction

The Filesystem iterator

## Class synopsis

class FilesystemIterator extends DirectoryIterator {
/* Constants */
public const int CURRENT_MODE_MASK;
public const int CURRENT_AS_PATHNAME;
public const int CURRENT_AS_FILEINFO;
public const int CURRENT_AS_SELF;
public const int KEY_MODE_MASK;
public const int KEY_AS_PATHNAME;
public const int FOLLOW_SYMLINKS;
public const int KEY_AS_FILENAME;
public const int NEW_CURRENT_AND_KEY;
public const int OTHER_MODE_MASK;
public const int SKIP_DOTS;
public const int UNIX_PATHS;
/* Methods */
public function __construct(string `$directory`, int `$flags` = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS)
public function current(): string|SplFileInfo|FilesystemIterator
public function getFlags(): int
public function key(): string
public function next(): void
public function rewind(): void
public function setFlags(int `$flags`): void
/* Inherited methods */
public function DirectoryIterator::current(): mixed
public function DirectoryIterator::getBasename(string `$suffix` = ""): string
public function DirectoryIterator::getExtension(): string
public function DirectoryIterator::getFilename(): string
public function DirectoryIterator::isDot(): bool
public function DirectoryIterator::key(): mixed
public function DirectoryIterator::next(): void
public function DirectoryIterator::rewind(): void
public function DirectoryIterator::seek(int `$offset`): void
public function DirectoryIterator::__toString(): string
public function DirectoryIterator::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
}

## Predefined Constants

`FilesystemIterator::CURRENT_AS_PATHNAME`

  Makes FilesystemIterator::current() return the pathname.

`FilesystemIterator::CURRENT_AS_FILEINFO`

  Makes FilesystemIterator::current() return an SplFileInfo instance.

`FilesystemIterator::CURRENT_AS_SELF`

  Makes FilesystemIterator::current() return $this (the FilesystemIterator).

`FilesystemIterator::CURRENT_MODE_MASK`

  Masks FilesystemIterator::current()

`FilesystemIterator::KEY_AS_PATHNAME`

  Makes FilesystemIterator::key() return the pathname.

`FilesystemIterator::KEY_AS_FILENAME`

  Makes FilesystemIterator::key() return the filename.

`FilesystemIterator::FOLLOW_SYMLINKS`

  Makes RecursiveDirectoryIterator::hasChildren() follow symlinks.

`FilesystemIterator::KEY_MODE_MASK`

  Masks FilesystemIterator::key()

`FilesystemIterator::NEW_CURRENT_AND_KEY`

  Same as `FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::CURRENT_AS_FILEINFO`.

`FilesystemIterator::OTHER_MODE_MASK`

  Mask used for FilesystemIterator::getFlags() and FilesystemIterator::setFlags().

`FilesystemIterator::SKIP_DOTS`

  Skips dot files (`.` and `..`).

`FilesystemIterator::UNIX_PATHS`

  Makes paths use Unix-style forward slash irrespective of system default. Note that the `path` that is passed to the constructor is not modified.

## Table of Contents

- FilesystemIterator::__construct — Constructs a new filesystem iterator
- FilesystemIterator::current — The current file
- FilesystemIterator::getFlags — Get the handling flags
- FilesystemIterator::key — Retrieve the key for the current file
- FilesystemIterator::next — Move to the next file
- FilesystemIterator::rewind — Rewinds back to the beginning
- FilesystemIterator::setFlags — Sets handling flags

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