note 10176 added to get_class_vars

From: Date: Sun, 17 Dec 2000 01:57:21 +0000
Subject: note 10176 added to get_class_vars
Groups: php.notes 
Request: Send a blank email to php-notes+get-8799@lists.php.net to get a copy of this message
/**** BEGIN OF CODE ****/ class xyz { var $x = 999; var $y = 123; function abc() { $this->$x = 0; } function abc1() { $this->$x = 1; } function abc2() { $this->$x = 2; } function abc3() { $this->$x = 3; } function abcx() { print $this->$x + $this->$y; } } $my_class = new xyz(); // print all methods of $my_class $arr = get_class_methods(get_class($my_class)); for ($i=0;$i<count($arr);$i++) print "Function $i : $arr[$i]\n"; print "\n"; // print default properties of $my_class $arr = get_class_vars(get_class($my_class)); while(list($key,$val) = each($arr)) print "Properties $key has value : $val\n"; /***** END OF CODE *****/ The result : Function 0 : abc Function 1 : abc1 Function 2 : abc2 Function 3 : abc3 Function 4 : abcx Properties x has value : 999 Properties y has value : 123 rgds, LexZEUS http://www.php.net/manual/function.get-class-vars.php

« previous php.notes (#8799) next »