PHP/Reflection/get class vars

Материал из Web эксперт
Перейти к: навигация, поиск

get_class_vars() function returns an array of attributes defined in the class specified by class_name.

 
//Its syntax is: array get_class_vars (string class_name)
//Using get_class_vars() to create $attribs

<?
class Vehicle {
     var $model;
     var $current_speed;
}
class Airplane extends Vehicle {
     var $wingspan;
}
$a_class = "Airplane";
$attribs = get_class_vars($a_class);
print_r($attribs);
?>