PHP4: Get Calling Function Name?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sunfish62
Forum Newbie
Posts: 7
Joined: Thu Sep 15, 2005 1:43 pm
Location: California

PHP4: Get Calling Function Name?

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

debug_backtrace() : yer full callin' stacks, arrr.
sunfish62
Forum Newbie
Posts: 7
Joined: Thu Sep 15, 2005 1:43 pm
Location: California

Post by sunfish62 »

Thanks. I knew it had to be in there. I just couldn't find it.
Post Reply