get_object_vars
Returns an associative array of object properties
Description
arrayget_object_vars
objectobj
This function returns an associative array of defined object properties
for the specified object obj. If variables
declared in the class of which the obj is an
instance, have not been assigned a value, those will not be returned
in the array.
Use of get_object_vars
x = $x;
$this->y = $y;
}
function setLabel($label) {
$this->label = $label;
}
function getPoint() {
return array("x" => $this->x,
"y" => $this->y,
"label" => $this->label);
}
}
// "$label" is declared but not defined
$p1 = new Point2D(1.233, 3.445);
print_r(get_object_vars($p1));
$p1->setLabel("point #1");
print_r(get_object_vars($p1));
?>
]]>
The printout of the above program will be:
1.233
[y] => 3.445
)
Array
(
[x] => 1.233
[y] => 3.445
[label] => point #1
)
]]>
See also get_class_methods and
get_class_vars!