PHP4: Get Calling Function Name?
Posted: Thu Sep 15, 2005 1:55 pm
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
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