日期:2014-05-17 浏览次数:20571 次
<?php class a { public function a(){echo a;} /*b*/ public function b() {echo b;} //c public function c(){ echo c; } } ?>
class a { public function a(){echo a; } /*b*/ public function b(){ echo b; } //c public function c(){ echo c; } } $class = new ReflectionClass('a'); $method=$class->getMethod('b'); $filename=$method->getFileName();//获取文件名 $start=$method->getStartLine();//获取方法起始行 $length=$method->getEndLine()-$start;//获取方法体长度 $source=file($filename); $code = implode('',array_slice($source,$start-1,$length+1)); echo $code; /* public function b(){ echo b; } */