您还可以使用php异常提供的信息,这是一个优雅的解决方案:
function GetCallingMethodName(){
$ e = new Exception();
$ trace = $ e-> getTrace();
//位置0将是调用此函数的行,因此我们忽略它
$ last_call = $ trace [1];
的print_r($ last_call);
}
function firstCall($ a,$ b){
theCall($ a,$ b);
}
function theCall($ a,$ b){
GetCallingMethodName();
}
firstCall('lucia','php');
你得到这个......(瞧!)
排列
(
[file] => /home/lufigueroa/Desktop/test.php
[line] => 12
[function] => theCall
[args] =>数组
(
[0] =>露西亚
[1] => php
)
)