|
Posted by Rik Wasmus on 01/07/08 23:43
On Tue, 08 Jan 2008 00:31:57 +0100, Steve <no.one@example.com> wrote:
> "devloop" <andrea2004@gmx.de> wrote in message
> news:a21e6087-932a-4683-95d0-3d1d65d7288e@s19g2000prg.googlegroups.com...
> Thank you soooo much! That´s it! I would have cost me years to find
> that as in JAVA you may write this or leave it!
>
> Do I have to add any include line to use iterator class or
> collections? Do they exist in php?
>
> ===========
>
> no.
Yes, Iterators exist, as the are an interface for a class.
> there is very little strong typing in php
Which has to do with?
> and an array has the
> enumerable interface. anything you put in an array can be iterated with
> foreach
Yes, however, creating an object as an ArrayObject/implementing
ArrayIterator, and private variables, will give you the possibility for
type hinting:
class MyCollection implements ArrayIterator{
...
private $values = array();
public function add(MyParticularObject $value){
$this->values[] = $value;
}
}
--
Rik Wasmus
[Back to original message]
|