开发者

Name and parameters of parent function

I'm trying to figure out h开发者_运维知识库ow to get the name and parameters of a parent function.

Example:

function foo($a,$b){
  bar();
}

function bar(){
  // Magic Print
}

foo('hello', 'world');

Output:

foo('hello','world')

Any tips?


You can get the information from debug_backtrace().

function bar(){
  $backtrace = debug_backtrace();
  $t = $backtrace[1];
  print $t["function"] . "('" . implode("','", $t["args"]) . "')\n";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜