get_class_vars() & get_class_methods()

get_class_vars() & get_class_methods()

get_class_vars()
===========

get_class_vars
- It returns an array of default properties of the class
This function will return an associative array of default properties of the class. The resulting array elements are in the form of varname => value.

Syntax:
=====
array get_class_vars ( string class_name)

get_class_methods()
===============

get_class_methods
It returns an array of class methods’ names
This function returns an array of method names defined for the class specified by class_name.

Syntax:
=====
array get_class_methods ( mixed class_name)

Example:
=======

class Myclass {

var $var1;
var $var2 = “xyz”;
var $var3 = 100;
function sample1() {}
function sample2() {}
}

$my_class = new Myclass();
$str = get_class($my_class);
$variables = get_class_vars($str);
$functionnames = get_class_methods($str);
print_r($variables);
echo “


“;
print_r($functionnames);

The result of the $variables array is

(
[var1] =>
[var2] => xyz
[var3] => 100
)

The result of the $functionnames array is

Array
(
[0] => sample1
[1] => sample2
)

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.