get_class_vars

array get_class_vars(string class_name) 

Gets the member variables (and their default values) for a class.

Returns:

Associative array; FALSE if class_name is not the name of a defined class

get_class_vars() finds the names of the member variables for a given class and returns them as an associative array containing the name of the object’s member variables as array keys and the default values of the member variables as array values.

Availability:

UNIX, Windows

Version:

4.0RC1+

See also:

get_object_vars() 
method_exists() 

Example:

Display the member variables and their default values for a class
 class location { var $x_axis = 0; var $y_axis = 0; var $z_axis = 0; } // Find the member variables of the location class $var_names ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.