Get called-from informaiton

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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Get called-from informaiton

Post by infolock »

Is there a way to get information on a file and line # where a call to a specific function was made?

In other words, say I have the function Foo() in class Bar. In the file test.php, it calls Bar::Foo() on line 15. I want to be able to, in the function Foo(), say "Ok, I was called from test.php on line 15".

Just wondering. I know I can pass this information to the function, just wondering if there was a quicker and more efficient method.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

debug_backtrace() has all the details of the call stack. :)
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

very nice. i forgot all about that one =) thanks.
Post Reply