for the example object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class Test{ //public props public $var1="Value 1"; public $var2="Value 2"; public $var3="Value 3"; //private props private $var4="Value 4"; //public method public function public_function(){ return true; } //private method private function private_function(){ return true; } } |
You can cycle through the public object properties as you would with an array:
1 2 3 4 5 6 | $test=new Test(); foreach($test as $prop_name=>$prop_value){ print $prop_name.'=>'.$prop_value; print "<br".">"; } |
The result will be:
var1=>Value 1 var2=>Value 2 var3=>Value 3
