Copy code The code is as follows:
class myclass {
var $var1;
var $var2 = 'xyz';
var $var3 = 100;
private $var4;
function myclass () {
$this->val1 = "foo";
$this->val2 = "bar";
return true;
}
function test1() {
return true;
}
}
// get_class_methods() returns an array consisting of the method names of the class
get_class_methods('myclass') or get_class_methods(new myclass());
//get_class() returns the class name of the object
//get_class_vars() returns the default value of the class Array of attributes
$my_class = new myclass();
$class_vals = get_class_vars(get_class($my_class));
foreach($class_vars as $name => $value) {
echo "$name : $valuen< br/>";
}
?>
The above introduces the implementation code of pretty rhythm dear my future PHP to obtain the attributes and methods of a class, including the content of pretty rhythm dear my future. I hope it will be helpful to friends who are interested in PHP tutorials.