# The RecursiveDirectoryIterator class

(PHP 5, PHP 7)

## Introduction

The RecursiveDirectoryIterator provides an interface for iterating recursively over filesystem directories.

## Class synopsis

RecursiveDirectoryIterator extends FilesystemIterator implements SeekableIterator , RecursiveIterator {
/* Inherited constants */
const int FilesystemIterator::CURRENT_AS_PATHNAME = 32 ;
const int FilesystemIterator::CURRENT_AS_FILEINFO = 0 ;
const int FilesystemIterator::CURRENT_AS_SELF = 16 ;
const int FilesystemIterator::CURRENT_MODE_MASK = 240 ;
const int FilesystemIterator::KEY_AS_PATHNAME = 0 ;
const int FilesystemIterator::KEY_AS_FILENAME = 256 ;
const int FilesystemIterator::FOLLOW_SYMLINKS = 512 ;
const int FilesystemIterator::KEY_MODE_MASK = 3840 ;
const int FilesystemIterator::NEW_CURRENT_AND_KEY = 256 ;
const int FilesystemIterator::SKIP_DOTS = 4096 ;
const int FilesystemIterator::UNIX_PATHS = 8192 ;
/* Methods */
public __construct ( string `$path` [, int `$flags` = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO ] )
public getChildren ( ) : mixed
public getSubPath ( ) : string
public getSubPathname ( ) : string
public hasChildren ([ bool `$allow_links` = `FALSE` ] ) : bool
public key ( ) : string
public next ( ) : void
public rewind ( ) : void
/* Inherits */
public FilesystemIterator::__construct ( string `$path` [, int `$flags` = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS ] )
public FilesystemIterator::current ( ) : mixed
public FilesystemIterator::getFlags ( ) : int
public FilesystemIterator::key ( ) : string
public FilesystemIterator::next ( ) : void
public FilesystemIterator::rewind ( ) : void
public FilesystemIterator::setFlags ([ int `$flags` ] ) : void
}

## Changelog

Version | Description
--- | ---
5.3.0 | The FilesystemIterator was introduced as the parent class. Previously, the parent was the DirectoryIterator.
5.3.0 | Implements SeekableIterator.
5.2.11, 5.3.1 | Added `RecursiveDirectoryIterator::FOLLOW_SYMLINKS`

## Table of Contents

- RecursiveDirectoryIterator::__construct — Constructs a RecursiveDirectoryIterator
- RecursiveDirectoryIterator::getChildren — Returns an iterator for the current entry if it is a directory
- RecursiveDirectoryIterator::getSubPath — Get sub path
- RecursiveDirectoryIterator::getSubPathname — Get sub path and name
- RecursiveDirectoryIterator::hasChildren — Returns whether current entry is a directory and not '.' or '..'
- RecursiveDirectoryIterator::key — Return path and filename of current dir entry
- RecursiveDirectoryIterator::next — Move to next entry
- RecursiveDirectoryIterator::rewind — Rewind dir back to the start