Page 1 of 1

PHP4: Get Calling Function Name?

Posted: Thu Sep 15, 2005 1:55 pm
by sunfish62
I am working on a project with a bunch of separate classes that all inherit a single method for error handling. I set up my error routine in the base class so that it identifies the class and method in which the error occurred, along with specifics for the error.

Identifying the class is trivial with the PHP get_class() function.

However, the only way that I have been able to get the active method is to manually set it in each method as a property of the object, which I then output in the error routine. What I would rather have is some way in the set_err method to track the calling method name and eliminate this messy kludge. In other words:

If ThisClass->SomeFunction() trips an error, I want ThisClass->set_err() to be able to know that SomeFunction called it.

I am working with PHP4.

TIA,
David

Posted: Thu Sep 15, 2005 6:04 pm
by feyd
debug_backtrace() : yer full callin' stacks, arrr.

Posted: Fri Sep 16, 2005 2:39 pm
by sunfish62
Thanks. I knew it had to be in there. I just couldn't find it.