This article analyzes the usage of get_object_vars() method in PHP with examples. Share it with everyone for your reference. The specific analysis is as follows:
Syntax: get_object_var($object), returns an array. Get the attributes in the $object object and form an array
Example:
<?php class person{ public $name="王美人"; public $age = 25; public $birth; } $p = new person(); print_r(get_object_vars($p)); ?>
Output result:
Array ( [name] => 王美人 [age] => 25 [birth] => )
I hope this article will be helpful to everyone’s PHP programming design.