The Iterator and IteratorAggregate interfaces make it easy for you to provide foreach support over an object that contains child elements. Although you could have implemented the Iterator interface directly in the Collection class, doing so would have unnecessarily cluttered that class's API. By separating the iteration capabilities into a separate class, you maintain a cleaner code base.

Use the clone operator when you need to make a copy of an object. Early release versions of the PHP5 documentation showed example code that directly invoked the__clone() method. This is no longer supported. Use the clone operator instead. If you have special needs for the copying of your objects, you can implement your own__clone() method.

The Collection and CollectionIterator classes provide a powerful OO mechanism for handling groups of objects. Although there is a fair amount of code between these two classes, you need to write it only once. You'll be able to reuse it verbatim in all your applications.

Professional PHP5 (Programmer to Programmer Series)
Professional PHP5 (Programmer to Programmer Series)
Year: 2003
Pages: 182 © 2008-2017.
If you may any questions please contact us: