English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Class/Object function reference manual
The get_class_vars() function returns an array composed of the default properties of the class
get_class_vars( \$class_name );
This function retrieves the default properties of the given class. Returns an associative array of the default public properties of the class.
Serial number | Parameters and descriptions |
---|---|
1 | class_name(Required) Class name. |
It returns an associative array of default public properties of the class. The form of the array elements is varname => value. If an error occurs, FALSE is returned.
The following is the usage of this function, returning an array composed of default properties of the class
<?php class helloworld { var \$var1; var \$var2 = "xyz"; var \$var3 = 100; private \$var4; // PHP 5 function helloworld() { \$this->var1 = "foo"; \$this->var2 = "bar"; return true; } } \$hello_class = new helloworld(); \$class_vars = get_class_vars(get_class(\$hello_class)); foreach (\$class_vars as \$name => \$value) { echo "\$name : \$value \n"; } ?>Test and see‹/›
It will produce the following result-
var1 : var2 : xyz var3 : 100