[thelist] Q on PHP functions...

jsWalter jsWalter at torres.ws
Tue Apr 6 14:10:32 CDT 2004


> -----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




More information about the thelist mailing list