PHP获取指定函数定义在哪个文件中以及其所在的行号实例_PHP教程
function a() {
}
class b {
public function f() {
}
}
function function_dump($funcname) {
try {
if(is_array($funcname)) {
$func = new ReflectionMethod($funcname[0], $funcname[1]);
$funcname = $funcname[1];
} else {
$func = new ReflectionFunction($funcname);
}
} catch (ReflectionException $e) {
echo $e->getMessage();
return;
}
$start = $func->getStartLine() - 1;
$end = $func->getEndLine() - 1;
$filename = $func->getFileName();
echo "function $funcname defined by $filename($start - $end)\n";
}
function_dump('a');
function_dump(array('b', 'f'));
$b = new b();
function_dump(array($b, 'f'));
?>
上一篇: 请教用openoffice在pdf中提取文本的php代码
下一篇: oracle SQL解析步骤小结