获取在php上调用的文件和行?

时间:2014-05-07 19:28:22

标签: php

<?php
//lets say one of these files have the function test();
include 'a.php';
include 'b.php';
include 'c.php';
include 'd.php';

test();
?>

如何找出调用哪个文件和行函数test()? (不打开文件)谢谢

1 个答案:

答案 0 :(得分:1)

您可以使用reflection with PHP

$func = new ReflectionFunction('test');
echo $func->getFileName();
echo $func->getStartLine();