array get_object_vars(object $obj)返回$obj对象的所有的非静态属性。
eg:
<?php class Animal { public $cat = 4; protected $fox = 4; private $pig = 3; private $mouse = 3; public function PrintNum() { print_r(get_object_vars($this)); print("<br>"); } } $a = new Animal; $a->PrintNum(); print_r(get_object_vars($a)); ?>
输出:Array ( [cat] => 4 [fox] => 4 [pig] => 3 [mouse] => 3 )
Array ( [cat] => 4 )