2
SPL: ArrayObject/Iterator from IteratorAggregate
4
<?php if (!extension_loaded("spl")) print "skip"; ?>
8
// This test also needs to exclude the protected and private variables
9
// since they cannot be accessed from the external object which iterates
12
class test implements IteratorAggregate
14
public $pub = "public";
15
protected $pro = "protected";
16
private $pri = "private";
18
function __construct()
20
$this->imp = "implicit";
23
function getIterator()
25
$it = new ArrayObject($this);
26
return $it->getIterator();
31
$test->dyn = "dynamic";
35
print_r($test->getIterator());
37
foreach($test as $key => $val)
39
echo "$key => $val\n";
49
[pro:protected] => protected
50
[pri:private] => private
57
[pro:protected] => protected
58
[pri:private] => private