Implementing the traversable Iterator
<?php class IterateExample { public $var_one = 1; public $var_two = 2; private $var_three = 3; public $var_four = 4; } $inst = new IterateExample(); foreach($inst as $key => $value) { echo "$key = $value\n"; } ?>