English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Class/Object function reference manual
The get_object_vars() function returns an associative array composed of object properties
get_object_vars($object);
This function gets the properties of the given object.
Serial number | Parameters and descriptions |
---|---|
1 | object Object instance. |
Returns an associative array of non-static properties of the specified object in the scope. If no value is assigned to the property, it returns a NULL value.
The following is the usage of this function-
<?php class Point2D { var $x, $y; var $label; function Point2D($x, $y) { $this->x = $x; $this->y = $y; } function setLabel($label) { $this->label = $label; } function getPoint() { return array("x" => $this->x, "y" => $this->y, "label" => $this->label); } } $p1 = new Point2D(1.233, 3.445); print_r(get_object_vars($p1)); $p1->setLabel("point #1); print_r(get_object_vars($p1)); ?>Test and see‹/›
It will produce the following results-
Array ( [x] => 1.233 [y] => 3.445 [label] => ) Array ( [x] => 1.233 [y] => 3.445 [label] => point #1 )