# The DirectoryIterator class

(PHP 5, PHP 7)

## Introduction

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

## Class synopsis

DirectoryIterator extends SplFileInfo implements SeekableIterator {
/* Methods */
public __construct ( string `$path` )
public current ( ) : DirectoryIterator
public getATime ( ) : int
public getBasename ([ string `$suffix` ] ) : string
public getCTime ( ) : int
public getExtension ( ) : string
public getFilename ( ) : string
public getGroup ( ) : int
public getInode ( ) : int
public getMTime ( ) : int
public getOwner ( ) : int
public getPath ( ) : string
public getPathname ( ) : string
public getPerms ( ) : int
public getSize ( ) : int
public getType ( ) : string
public isDir ( ) : bool
public isDot ( ) : bool
public isExecutable ( ) : bool
public isFile ( ) : bool
public isLink ( ) : bool
public isReadable ( ) : bool
public isWritable ( ) : bool
public key ( ) : string
public next ( ) : void
public rewind ( ) : void
public seek ( int `$position` ) : void
public __toString ( ) : string
public valid ( ) : bool
}

## Changelog

Version | Description
--- | ---
5.1.2 | DirectoryIterator extends SplFileInfo.

## Table of Contents

- DirectoryIterator::__construct — Constructs a new directory iterator from a path
- DirectoryIterator::current — Return the current DirectoryIterator item
- DirectoryIterator::getATime — Get last access time of the current DirectoryIterator item
- DirectoryIterator::getBasename — Get base name of current DirectoryIterator item
- DirectoryIterator::getCTime — Get inode change time of the current DirectoryIterator item
- DirectoryIterator::getExtension — Gets the file extension
- DirectoryIterator::getFilename — Return file name of current DirectoryIterator item
- DirectoryIterator::getGroup — Get group for the current DirectoryIterator item
- DirectoryIterator::getInode — Get inode for the current DirectoryIterator item
- DirectoryIterator::getMTime — Get last modification time of current DirectoryIterator item
- DirectoryIterator::getOwner — Get owner of current DirectoryIterator item
- DirectoryIterator::getPath — Get path of current Iterator item without filename
- DirectoryIterator::getPathname — Return path and file name of current DirectoryIterator item
- DirectoryIterator::getPerms — Get the permissions of current DirectoryIterator item
- DirectoryIterator::getSize — Get size of current DirectoryIterator item
- DirectoryIterator::getType — Determine the type of the current DirectoryIterator item
- DirectoryIterator::isDir — Determine if current DirectoryIterator item is a directory
- DirectoryIterator::isDot — Determine if current DirectoryIterator item is '.' or '..'
- DirectoryIterator::isExecutable — Determine if current DirectoryIterator item is executable
- DirectoryIterator::isFile — Determine if current DirectoryIterator item is a regular file
- DirectoryIterator::isLink — Determine if current DirectoryIterator item is a symbolic link
- DirectoryIterator::isReadable — Determine if current DirectoryIterator item can be read
- DirectoryIterator::isWritable — Determine if current DirectoryIterator item can be written to
- 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