Re: Declare Function
| From: | Frappy John | Date: | Tue, 15 Apr 2003 04:42:22 +0000 |
| Subject: | Re: Declare Function | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143864@lists.php.net to get a copy of this message | ||
Burhan:
You asked a very good question. I've wondered if there's a
good use for PHP's declared constants too. And I hope
someone who understands them replies with a good
explanation.
I see where one reply so far identified them as a
"constant." That's PHP's term. But they aren't really
constants in the traditional sense since you can't use them
in expressions.
I see where another reply called them "execution
parameters," (which to my mind is just a fancy term for
"constant").
They remind me more of compile-time parameters. (Actually
they remind me of assembly-time parameters.) But since PHP
isn't compiled (or is compiled transparently at execution
time), I suppose "execution parameters" is as
good a term for them as any.
I've been able to spin some pretty sophisticated systems
without ever using these "constants". If I need a constant,
I define a variable using a name in all-caps (so I'll
remember not to change it). That way I can use it in
regular conditions and expressions.
It's possible their proper use could lead to efficiencies
if they can be used to avoid the JIT compilation of large
blocks of unused code (i.e. conditional compilation). But I
don't know that that's the case.
Does anyone know?
--Frappy
On Monday 14 April 2003 06:07 pm, lists@linuxgroup.net
wrote:
> I haven't done anything with declare before, so could you
> give me a brief explanation of what "execution
> parameters" are. Or, when it would be better to use
> declare. Thanks!
>
> Burhan Khalid <phplist@meidomus.com> wrote:
> > Hello lists,
> >
> > Monday, April 14, 2003, 4:48:24 PM, you wrote:
> >
> > lln> Whats the difference between
> >
> >
> > lln> $var = "blah";
> >
> > This declares a variable.
> >
> > lln> declare('var', 'blah');
> >
> > This defines execution parameters for a block of code.
> > Two very different things.
> >
> > --
> > Burhan Khalid
> > phplist[at]meidomus[dot]com
> >
> > Please add reply-to: header with
> > the list's email address for proper
> > correspondence.
>
> _________________________________________________________
>__ This mail sent using V-webmail -
> http://www.v-webmail.co.uk