- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
get_class_vars() function in PHP
The get_class_var() function get the default properties of the class. It returns an associative array of declared properties visible from the current scope, with their default value.
Syntax
get_class_vars(name_of_class)
Parameters
name_of_class − The class name
Return
The get_class_vars() function returns an associative array of declared properties visible from the current scope, with their default value. The resulting array elements are in the form of varname => value.
Example
The following is an example −
<?php class Demo { var $myvar1 = "xy"; var $myvar2 = "abcd"; var $myvar3 = 7; var $myvar4 = 20; var $myvar5 = 90; private $var4; function Demo() { $this->myvar1 = "ab"; $this->myvar2 = "cd"; return true; } } $hello_class = new Demo(); $class_vars = get_class_vars(get_class($hello_class)); foreach ($class_vars as $name => $value) { echo "$name = $value
"; } ?>
Output
The following is the output −
myvar1 = xy myvar2 = abcd myvar3 = 7 myvar4 = 20 myvar5 = 90
Advertisements