get_object_vars
Description
The get_object_vars of Class / Object for PHP gets the properties of the given object.
Syntax
get_object_vars ( object $object ) : array
Parameters
object
An object instance.
Return
Returns an associative array of defined object accessible non-static properties for the specified object in scope.
Examples
1
<? class myclass { public $var1 = "public"; protected $var2 = "protected"; private $var3 = "private"; static $var4 = "static"; function myfunction() { $return = get_object_vars($this); print_r($return); } } $object = new myclass; $return = get_object_vars($object); print_r($return); $object->myfunction(); ?>
Array ( [var1] => public ) Array ( [var1] => public [var2] => protected [var3] => private )