how to find what file/object/line is calling a method?

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
dhinge
Forum Newbie
Posts: 12
Joined: Mon Jan 08, 2007 1:56 pm

how to find what file/object/line is calling a method?

Post by dhinge »

Some process is calling a method in a class, and I'm not sure which one it is. Is there a way to find out what exactly is running the method?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: how to find what file/object/line is calling a method?

Post by jayshields »

You could use __LINE__ and __FILE__.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: how to find what file/object/line is calling a method?

Post by Mark Baker »

have a look at debug_backtrace()
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: how to find what file/object/line is calling a method?

Post by Mirge »

Mark Baker wrote:have a look at debug_backtrace()
Quite useful! Wasn't aware of this function... even though I'm not the OP, thank you :).
Post Reply