O'Reilly logo

Upgrading to PHP 5 by Adam Trachtenberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Iterator and SPL Classes and Interfaces

This chapter demonstrates many classes, abstract classes, and interfaces, yet it only begins to touch on the full nature of SPL.

Table 6-3 is a quick-reference guide to the complete collection of SPL iterators, including some not mentioned in this chapter. For more information, see the SPL section of the PHP Manual at http://www.php.net/spl.

Table 6-3. Iterator and SPL classes and interfaces

Name

Type

Relationship

Description

ArrayObject

Class

Implements IteratorAggregate interface

Converts arrays and objects into iterators

ArrayIterator

Class

Implements Iterator interface

Used by ArrayObject; cannot be instantiated directly

CachingIterator

Class

Implements Iterator interface

Provides “look ahead by one” capability using hasNext( )

CachingRecursiveIterator

Class

Extends CachingIterator class; implements RecursiveIterator interface

Adds caching support to recursive iterators

DirectoryIterator

Class

Implements Iterator interface

An iterator for directory files

FilterIterator

Abstract class

Implements Iterator interface

Allows filtering of other iterators using accept( ) method

Iterator

Interface

Defines Iterator interface

Implements an iterator

IteratorAggregate

Interface

Defines IteratorAggregate interface

Allows classes to control iteration by returning iterator from getIterator( ) method

LimitIterator

Class

Implements Iterator interface

Emulates database LIMIT clause

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required