I am Studying about PHP SPL - (Standard PHP Library), And i am having some problems understanding the interface Iterator.

I am studying from this example:Iterator Interface.

And i am really dont understand how does Iterator Interface allow us to run with a "foreach" loop trough the class elements, I will be very thankful if some one can please pass me trough this code, Thank you all and have a nice day.

有帮助吗?

解决方案

The interface defines a couple of functions that are needed to allow you to "run with a foreach loop". The whole idea is that there is no code, just an interface.

The functions are listed in the manual, and there is also an example with code on how to use them:

http://php.net/manual/en/class.iterator.php

Can't be clearer than that really.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top