php 反射机制查看
1.查看类属性以及方法
single.php class single { private static $instance; public function __construct() {} /**@return single */ public static function getInstance() { if(!isset(self::$instance)) { self::$instance = new single(); } return self::$instance; } private function combine(){} } info.php require_once('single.php'); $res = new ReflectionClass(single); echo '<pre>'; print_r($res->getMethods()); print_r($res->getProperties());
结果
Array ( [0] => ReflectionMethod Object ( [name] => __construct [class] => single ) [1] => ReflectionMethod Object ( [name] => getInstance [class] => single ) [2] => ReflectionMethod Object ( [name] => combine [class] => single ) ) Array ( [0] => ReflectionProperty Object ( [name] => instance [class] => single ) )
如上返回single类的方法,属性
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23