get_object_vars and get_class_vars

get_object_vars and get_class_vars

get_class_vars
This function will return array which contains all the default and public properties of the class

get_object_vars
This function will return array which contains all the default and public properties of an object.

Example:

class Test{
public $tmp1;
public $tmp2;
public static $tmp3;

public function function1(){
echo “function1″;
}
public function function2(){
echo “function2″;
}
}

$objTest = new Test;

$clVars = get_class_vars(”Test”);

print_r($clVars);

$obVars = get_object_vars($objTest);

print_r($obVars);

1. print_r($clVars) will print following array
Array ( [tmp1] => [tmp2] => [tmp3] => )
2.print_r($obVars);will print following array
Array ( [tmp1] => [tmp2] => ).
tmp3 is static member of the class. So it is not come here.

The above is the basic difference between get_class_vars and get_object_vars

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.