|
Sommaire
Objets
Introduction
call_user_method
call_user_method_array
class_exists
get_class
get_class_methods
get_class_vars
get_declared_classes
get_object_vars
get_parent_class
is_subclass_of
method_exists
|
6.9.9 get_object_varsPHP 4 >= 4.0.0Description
array get_object_vars(object obj )
get_object_vars retourne un tableau associatif
contenant les propriétés de l'objet obj.
Les clés du tableau sont les noms des propriétés
de l'objet.Si des variables déclarées dans la classe de
l'objet obj, n'ont pas été
assignées, elles ne seront pas retournées dans le tableau.
| Exemple avec get_object_vars |
<?php class Point2D { var $x, $y; var $nom; function Point2D($x, $y) { $this->x = $x; $this->y = $y; } function donne_nom($nom) { $this->nom = $nom; } function LitPoint() { return array("x" -> $this->x, "y" -> $this->y, "nom" -> $this->nom); } } $p1 = new Point2D(1.233, 3.445); print_r(get_object_vars($p1)); // "$nom" est déclaré, mais non défini // Array // ( // [x] -> 1.233 // [y] -> 3.445 // ) $p1->setnom("point #1"); print_r(get_object_vars($p1)); // Array // ( // [x] -> 1.233 // [y] -> 3.445 // [nom] -> point #1 // ) ?>
|
Voir aussi
get_class_methods et
get_class_vars
|