4

I'm trying to figure out how 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?

zaf
  • 22,776
  • 12
  • 65
  • 95

1 Answers1

5

You can get the information from debug_backtrace().

function bar(){
  $backtrace = debug_backtrace();
  $t = $backtrace[1];
  print $t["function"] . "('" . implode("','", $t["args"]) . "')\n";
}
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • Thank you. Thats what I would have done but my head has started getting heavy, time to take a break. I would accept your answer but SO has a time limit! – zaf May 11 '10 at 15:08