- var_dump: documentation ( source)
<?php
class myData implements IteratorAggregate {
public $property1 = "Public property one";
public $property2 = "Public property two";
public $property3 = "Public property three";
public function __construct() {
$this->property4 = "last property";
}
public function getIterator() {
return new ArrayIterator($this);
}
}
$obj = new myData;
echo "foreach (new \$obj)\n";
foreach($obj as $key => $value) {
var_dump($key, $value);
echo "\n";
}
echo "\nforeach (new ArrayIterator(\$obj))\n";
foreach(new ArrayIterator($obj) as $key => $value) {
var_dump($key, $value);
echo "\n";
}