/hphp/test/zend/bad/ext/spl/tests/array_007.php

http://github.com/facebook/hiphop-php · PHP · 39 lines · 27 code · 9 blank · 3 comment · 0 complexity · 164d060c899ab194efc8463f19d1b38b MD5 · raw file

  1. <?php
  2. // This test also needs to exclude the protected and private variables
  3. // since they cannot be accessed from the external object which iterates
  4. // them.
  5. class test implements IteratorAggregate
  6. {
  7. public $pub = "public";
  8. protected $pro = "protected";
  9. private $pri = "private";
  10. function __construct()
  11. {
  12. $this->imp = "implicit";
  13. }
  14. function getIterator()
  15. {
  16. $it = new ArrayObject($this);
  17. return $it->getIterator();
  18. }
  19. };
  20. $test = new test;
  21. $test->dyn = "dynamic";
  22. print_r($test);
  23. print_r($test->getIterator());
  24. foreach($test as $key => $val)
  25. {
  26. echo "$key => $val\n";
  27. }
  28. ?>
  29. ===DONE===
  30. <?php exit(0); ?>