Created
March 21, 2013 22:11
-
-
Save hrach/5217268 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestIterator implements \IteratorAggregate | |
{ | |
public function getIterator() | |
{ | |
return new ArrayIterator(array(1, 2, 3)); | |
} | |
} | |
class Test implements \IteratorAggregate | |
{ | |
public function getIterator() | |
{ | |
return new TestIterator(); | |
} | |
} | |
foreach (new Test as $v) { | |
echo $v; | |
} | |
// 123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment