php反射 获取类的源码

来源:互联网 发布:recyclerview的优化 编辑:程序博客网 时间:2024/06/05 02:54
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();                $lines = @file($path);                $from = $class->getStartLine();                $to = $class->getEndLine();                $len = $to-$from+1;                return implode(array_slice($lines, $from-1,$len));        }}print ReflectionUtil::getClassSourse( new ReflectionClass('test'));

0 0
原创粉丝点击