While I was in college for computer science, where the preferred academic language was C++, I came into contact with the STL (Standard Template Library). You can read more about that in this interview with Bjarne Stroustrup, but its intended purpose was pretty simple: to provide standard optimized implementations for a number of commonly used conceptual structures of the time.
If any PHP extension is underrated, it's probably the SPL (Standard PHP Library). From what I can tell without having been involved in its development, its purpose is somewhat similar to the STL. A while back, it was useful mainly for allowing class instances to be iterable and simulate array access. The old API documentation, while certainly better than none at all, is not very easy to sift through. The revitalized manual documentation is a fairly large improvement over its predecessor, but certainly isn't a replacement for a real reference guide. Despite this, using the SPL classes actually turned out to be pretty straightforward once you got your hands on a good starting guide or two to help you beat the learning curve.
This tutorial shows how dealin with directory structures is made more efficient within an Object Oriented framework. SPL iterators provide this same functionality for all aggregate structures, regardless of type.
Today I’ll look at some iterators: a set of classes in the SPL that implements various iterating patterns: ArrayIterator, AppendIterator, FilterIterator, LimitIterator and NoRewindIterator. Hopefully you’ll get a idea of what these are capable of and that you can get some new ideas for your day-to-day tasks.
Antony got the idea to implement a C-like array wrapper in SPL: SplFastArray. The main advantage of that class is performance, it's indeed faster than PHP arrays. How so? No free lunch: The speedup comes from the fact that non-numeric indexes are not allowed and that the array is of fixed size (which means no hashing and continuous memory storage).
Following my recent experiments with the new SPL features in PHP 5.3, I saw that there are some new SPL data structures: heap, stack, queue and linked list. They aren't documented yet but I had a peek at the C sources.
As its name implies, the goal of the Standard PHP Library-or SPL, for short-is to provide a standard library of interfaces that allows developers to take full advantage of object-oriented programming in PHP 5. This library of interfaces creates a standard API for certain kinds of built-in functionality, allowing your classes to interact with the PHP engine in a much more seamless manner. The functionality it provides includes, for example, the ability to define how your objects will react when iterated over with foreach, advanced array access, file and directory access, and advanced SimpleXML object handling. The largest chunk of functionality that the SPL provides comes in the form of iterators.
Here we are again. Welcome to the second tutorial of the series “Iterators in the simplest sense.” Just in case you didn’t know, this series introduces Iterators in PHP 4 – PHP 5, explaining their basic concepts, and teaches you how to use them in practical projects, which can be utilized as part of larger PHP applications.
This article, the first of two parts, explains how to use the Iterator pattern to manipulate any collection of objects. It is excerpted from chapter eight of the book PHP|architect's Guide to PHP Design Patterns, written by Jason E. Sweat (PHP|architect, 2005; ISBN: 0973589825).
While most of the excitement surrounding the release of PHP focused on its XML and object-oriented features, the Standard PHP Library (SPL) also saw some significant improvements that went mostly unnoticed. In the first of two articles covering the SPL, David Fells discusses the Exception class, which lets programs handle errors more gracefully and simplifies debugging.
Much of the buzz surrounding PHP5 has focused on its new object-oriented syntax and capabilities, and comparisons with Java. While all that was going on, the promisingly named "Standard PHP Library" (SPL) extension quietly made its way into the core PHP 5 distribution.








