get_object_vars()

来源:互联网 发布:诈骗罪立案后网络追逃 编辑:程序博客网 时间:2024/06/05 01:59

array get_object_vars(object $obj)返回$obj对象的所有的非静态属性。

eg:

<?phpclass  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 )


0 0