PHP反射类ReflectionClass和ReflectionObject
PHP中的扩展反射类,该扩展用来分析php程序,导出或提取出关于类、方法、属性、参数等的详细信息,包括注释。
复制代码 代码如下:
class test{
private $name;
private $sex;
function __construct(){
$this->aaa='aaa';
}
}
$test=new test();
$reflect=new ReflectionClass($test);
$pro=$reflect->getDefaultProperties();
print_r($pro);//打印结果:Array ( [name] => [sex] => )
echo $test->aaa;//打印结果:aaa
复制代码 代码如下:
class test{
private $name;
private $sex;
function __construct(){
$this->aaa='aaa';
}
}
$test=new test();
$reflect=new ReflectionObject($test);
$pro=$reflect->getProperties();
print_r($pro);
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号