[thelist] Q on PHP functions...

Ben Bright bright at seedling.com
Tue Apr 6 14:17:40 CDT 2004


I think the 

  debug_backtrace 

	http://us3.php.net/manual/en/function.debug-backtrace.php

function will get you what you want.

Careful, as it is only available after php v.4.3.0

~ben

On Tue Apr 06 14:10, jsWalter dreamt up the following:
> > -----Original Message-----
> > From: thelist-bounces at lists.evolt.org
> > [mailto:thelist-bounces at lists.evolt.org]On Behalf Of Richard Davey
> > Sent: Tuesday, April 06, 2004 1:19 PM
> > To: thelist at lists.evolt.org
> > Subject: Re: [thelist] Q on PHP functions...
> 
> > j> is it possible to display the name of the function within the current
> > j> function?
> >
> > j> function foo()
> > j> {
> > j>    echo <thisFuncName>;  // this should display 'foo'
> > j> }
> >
> > No, but then it's impossible for the echo statement to ever execute
> > without the function being called, so you always know the name of it
> > somehow.
> 
> On one hand, yes, your right.
> 
> Since I called the function, I should know what its name is.
> 
> What I'm trying to do is a "trace" display.
> 
> When I turn on $Trace = true, each function, in turn, will display its name
> as each is called.
> 
> Right now, I'm using this...
> 
>    if ($GLOBALS["TRACE"])
>       echo 'foobar()' . '<br />';
> 
> Yes this works, but, being the lazy sod I am, I'd like to have PHP do more
> of the work for me...
> 
>    if ($GLOBALS["TRACE"])
>       echo <auto_function_name>' . '<br />';
> 
> I use this on each file...
> 
>    if ( ( isset ( $GLOBALS["TRACE"] ) ) && ( $GLOBALS["TRACE"] ) )
>       echo __FILE__ . '<br />';
> 
> But, I guess this is not possible in PHP, based upon the few responses given
> to date.
> 
> Thanks anyway.
> 
> Walter
> 
> 
> -- 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 

-- 
--
-->> Ben Bright 
---->> bright at seedling.com 
------>>  http://seedling.com/
-------------------------------->>


More information about the thelist mailing list