Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to: Get function caller's name? 1

Status
Not open for further replies.

thenewa2x

Programmer
Dec 10, 2002
349
US
This is an example:

Code:
function example_func_1 ( )
{
  example_func_3();
}

function example_func_2 ( )
{
  example_func_3();
}

function example_func_3 ( )
{
  // I want this function to print out who called it,
  // example_func_1 or example_func_2.  I want it to
  // be dynamic therefore no arguments need to be passed
  // to identify who called it.  This way I can write more
  // functions and they will still be identified without
  // modifying example_func_3().

  print("example_func_3() was called by: " . something );
}

I also want to be able to do this will class methods:

Code:
class example_class
{

  function example_func_1 ( )
  {
    $this->example_func_3();
  }

  function example_func_2 ( )
  {
    $this->example_func_3();
  }

  function example_func_3 ( )
  {
    print("\$this->example_func_3() was called by: " . something );
  }

}

I hope I gave enough detail about what I want.

---------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top