class myClass{
public $a = "5";
public $b = "7";
public $c = "9";
function __tostring(){
return(var_export($this,TRUE));
}
}
$x = new myclass();
foreach($x as $attribute){
echo $attribute."<br />";
}
output:
5
7
9