|-摘 php反射获取自定义类的源码
注意:此方法只能获取自定义的类的源码,一般用IDE开发,都有自动找代码功能,所以此法用处不大。 class test{ private $name; ...
注意:此方法只能获取自定义的类的源码,一般用IDE开发,都有自动找代码功能,所以此法用处不大。
class test{
private $name;
function set($value){
$this->name = $value;
}
function get(){
return $this->name;
}
}
class reflectionUtil{
static function getClassSourse( ReflectionClass $class){
$path = $class->getFileName();
if($path){
$lines = @file($path);
$from = $class->getStartLine();
$to = $class->getEndLine();
$len = $to-$from+1;
return implode(array_slice($lines, $from-1,$len));
}else{
return 'not get code';
}
}
}
print ReflectionUtil::getClassSourse( new ReflectionClass('test'));
...
浏览更多内容请先登录。
立即注册
更新于:2018-02-07 02:18:06
相关内容
thinkphp6 和 thinkcmf6 多表联查并获取指定字段
PHP ==及===在获取$_GET[]或者$POST[]后的判断
php获取链接跳转的真实地址
PHP向js传数组
PHP与APP
PHP是否可以应用于App开发
推荐内容