Abstract
As you learned in the previous chapter, in order to control looping with the foreach statement, all objects must implement the Traversable interface. But, the Traversable interface is an internal-only interface, so trying to implement it in your userland classes will simply result in an error. To actually implement looping of your objects, you must implement Traversable via the Iterator or IteratorAggregate interface.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2008 Kevin McArthur
About this chapter
Cite this chapter
(2008). SPL Iterators. In: Pro PHP. Apress. https://doi.org/10.1007/978-1-4302-0279-0_10
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0279-0_10
Publisher Name: Apress
Print ISBN: 978-1-59059-819-1
Online ISBN: 978-1-4302-0279-0
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books