PHP 反射API 之 ReflectionObject 的用法实例
<?php
class C{
public $string;
public function __call($method,$args){
if(!isset($args)){
$args = $this->string;
}
if(function_exists($method)){
return $method($args);
}else{
return 'function not exists';
}
}
}
$O = new C();
$O->string = 'hello';
$reflect = new ReflectionObject($O);
var_dump($reflect->getmethods());
~
结果如下:
array(1) {
[0]=>
&object(ReflectionMethod)#3 (2) {
["name"]=>
string(6) "__call"
["class"]=>
string(1) "C"
}
}