get name of function within function
get name of function within function
am 17.04.2008 17:56:51 von Law Poop
Is there a way to find out the name of the function within the
function?
I'm doing troubleshooting of a page in which I call a lot of
functions. I had a simple error message pop up, which was okay back
when the page way simple. Now that the page has grown, it's a PITA to
find out where exactly the error message is being triggered. It would
be very helpful if I could find out which function I'm "in" when the
error message gets called.
Re: get name of function within function
am 17.04.2008 18:03:51 von zeldorblat
On Apr 17, 11:56 am, lawp...@gmail.com wrote:
> Is there a way to find out the name of the function within the
> function?
>
> I'm doing troubleshooting of a page in which I call a lot of
> functions. I had a simple error message pop up, which was okay back
> when the page way simple. Now that the page has grown, it's a PITA to
> find out where exactly the error message is being triggered. It would
> be very helpful if I could find out which function I'm "in" when the
> error message gets called.
Re: get name of function within function
am 17.04.2008 18:19:10 von luiheidsgoeroe
On Thu, 17 Apr 2008 18:03:51 +0200, ZeldorBlat
wrote:
> On Apr 17, 11:56 am, lawp...@gmail.com wrote:
>> Is there a way to find out the name of the function within the
>> function?
>>
>> I'm doing troubleshooting of a page in which I call a lot of
>> functions. I had a simple error message pop up, which was okay back
>> when the page way simple. Now that the page has grown, it's a PITA to
>> find out where exactly the error message is being triggered. It would
>> be very helpful if I could find out which function I'm "in" when the
>> error message gets called.
>
>
Or alternatively, do a debug_print_backtrace();, very nice when
troubleshooting.
--
Rik Wasmus
Re: get name of function within function
am 17.04.2008 18:34:46 von alvaroNOSPAMTHANKS
lawpoop@gmail.com escribió:
> I'm doing troubleshooting of a page in which I call a lot of
> functions. I had a simple error message pop up, which was okay back
> when the page way simple. Now that the page has grown, it's a PITA to
> find out where exactly the error message is being triggered. It would
> be very helpful if I could find out which function I'm "in" when the
> error message gets called.
You have a magic constant called __FUNCTION__ but what really want is a
backtrace:
http://php.net/debug_backtrace
You can call it from your own error handling function:
http://php.net/set_error_handler
http://php.net/set_exception_handler
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Re: get name of function within function
am 17.04.2008 19:33:07 von hellsop
On Thu, 17 Apr 2008 18:19:10 +0200, Rik Wasmus wrote:
> On Thu, 17 Apr 2008 18:03:51 +0200, ZeldorBlat
> wrote:
>
>> On Apr 17, 11:56 am, lawp...@gmail.com wrote:
>>> Is there a way to find out the name of the function within the
>>> function?
>>>
>>> I'm doing troubleshooting of a page in which I call a lot of
>>> functions. I had a simple error message pop up, which was okay back
>>> when the page way simple. Now that the page has grown, it's a PITA to
>>> find out where exactly the error message is being triggered. It would
>>> be very helpful if I could find out which function I'm "in" when the
>>> error message gets called.
>>
>>
>
> Or alternatively, do a debug_print_backtrace();, very nice when
> troubleshooting.
Best option for programmers, definately. For users, sometimes a
completely bizzare error message that doesn't mean ANYTHING gets better
reporting. "lock timeout" gets much less attention from users than "Why
did it just say it was out of tuna?", and since *I* know where the tuna
error message is, even though the message is actually "fainted from loss
of tuna", I can still find exactly where the failure was, and know what
to look for in logs.
--
Cunningham's Second Law:
It's always more complex than you expect, even when you take
Cunningham's Second Law into account.