<?php
/**
* A.php
* Created on 2020/8/5 8:21 下午
* Created by chenzhuo
* description :
*/
class A {
public $a = 1;
private $b = 2;
public static $instance = null;
/**
* A类的calm
* @return string
* User: chenzhuo
* Date: 2020/8/5 8:57 下午
*/
public function calm() {
return "calmA";
}
/**
* calmB
* @param int $type
* @return string
* User: chenzhuo
* Date: 2020/8/5 9:02 下午
*/
public function calmB($type=1) {
return "type:".$type;
}
}
//反射机制
$obj = new \A();
$obj2 = new \ReflectionClass($obj);
$instance = $obj2->newInstance(); //实例化类
$methods = $obj2->getMethods(); //获取类方法
foreach ($methods as $method){
$doc = $method->getDocComment(); //获取注释
}
$properties = $obj2->getProperties(); //获取属性
var_dump($properties);