Re: In need of better __FILE__, __LINE__ and __FUNCTION__ magic variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 25, 2010 at 10:59:43PM -0500, Robert Cummings wrote:

> Daevid Vincent wrote:
>> Like you, I have many little functions that are useful for debugging in a
>> page.
>>
>> The problem is that when you start to pepper them around, whilst debugging,
>> you can often times forget where you left them. A search isn't always
>> helpful since I sometimes leave them in the code, but commented out, so I
>> end up finding dozens of matches.
>>
>> What I need are some variables that tell me the current calling file, line
>> and function I'm in. Then when I see some debug info on the screen, I know
>> exactly where it came from.
>
> Use debug_backtrace() to capture the information from within the
> print_debug() or other deeper function. Just grab the second (or
> further) stack item that corresponds to the location where print_debug()
> was called.

+1

Or you can use debug_print_backtrace(), which directly outputs the
backtrace. I do this when my error handler encounters E_USER_ERROR and
the like.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux