Home Menu

get_object_vars

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

<?

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
)

Internal

get_class_vars

External

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms