Syntax
get_class_vars ( $class_name ); |
Definition and Usage
This function gets the default properties of the given class. Returns an associative array of default public properties of the class.
Paramters
Parameter | Description |
---|---|
class_name | Required. The class name. |
Return Value
Returns an associative array of default public properties of the class. The resulting array elements are in the form of varname => value.
Example
Following is the usage of this function:
<?php class myclass { var $var1; var $var2 = "xyz"; var $var3 = 100; private $var4; // PHP 5 function myclass() { $this->var1 = "foo"; $this->var2 = "bar"; return true; } } $my_class = new myclass(); $class_vars = get_class_vars(get_class($my_class)); foreach ($class_vars as $name => $value) { echo "$name : $value<br />"; } ?> |
It will produce following result:
var1 : var2 : xyz var3 : 100 |
No comments:
Post a Comment