Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Engine Yard Blog:
The Outer Iterator
Jan 13, 2014 @ 17:45:08

On the Engine Yard blog they have a new tutorial posted by Cal Evans looking at an object offered by the Standard PHP Library - the OuterIterator.

When PHP 5 arrived there was great excitement and rejoicing over the new object model. For many of us who struggled through PHP 4′s “Object Based” paradigm, PHP 5 was a ray of sunshine. We were so excited that many of us lost sight of another important addition to PHP 5, the Standard PHP Library (SPL).

Since then, the excitement over the object model has died down. Many authors and speakers have talked about, blogged about, and written about the SPL. However the SPL itself is a very large topic. We are going to narrow our focus down a bit to a subtopic of a specific section of the SPL. This blog post will deal with the OuterIterator. This is an interface defined in the SPL and used by several of the built in iterators.

He goes on to give a brief introduction about what the OuterIterator is and some examples uses for it, including one of the easier to follow - using it with a FilterIterator-based class. He gets into more detail about how the OuterIterator works and includes example snippets to help clarify. His "DwarfPrinter" class extends the FilterIterator and echoes out the names of The Seven Dwarves. He also includes an example of the output showing a more formatted output that follows the nesting and execution of the iterator. He finishes off the post with a list of iterators are useful to pair with the OuterIteator.

tagged: outeriterator tutorial filteriterator standardphplibrary spl

Link: https://blog.engineyard.com/2014/the-outer-iterator


Trending Topics: