pretty rhythm dear my future PHP obtains the implementation code of the attributes and methods of a class

WBOY
Release: 2016-07-29 08:45:13
Original
1171 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!