class MyClass{
/*
* Perhaps include the function comments
* in the function.
*/
function mainFunction(){
//Does Something
}
function functionWithArgs($arg1,$arg2=false){
//Does Something
//The function I want will give e the arguments w/default values
}
}
是否有一个函数或库可以让我对这个类甚至文件的信息进行某种访问.
恩.
get_file_outline( ‘fileWithAboveClass.PHP’);
要么
get_class_outline( ‘MyClass的’);
有没有人知道,或知道一种轻松写这个的方法?
解决方法:
//use the ReflectionClass to find out about MyClass
$classInfo = new ReflectionClass('MyClass');
//then you can find out pretty much anything you want to kNow...
$methods = $classInfo->getmethods();
var_dump($methods);
//you can even extract your comments, e.g.
$comment=$classInfo->getmethod('mainFunction')->getDocComment();