how to looping all property of Class
class object {
public $a = 1;
public $b = 2;
public $c = 3;
}
and the output will be
"property $a is 1";
"property $b is 2";
"property $c is 3";
You can use a foreach loop:
foreach (new object as $prop => $value) {
echo "property \$$prop is $value
";
}
You might take a look at get_object_vars()
, but not after taking a look at Polynomial's comment.