NYCPHP Meetup

NYPHP.org

[nycphp-talk] constants vs globals

David Mintz dmintz at davidmintz.org
Fri Feb 20 16:43:02 EST 2004


On Fri, 20 Feb 2004, Hans Zaunere wrote:

>
> > At the PHP conference in New York last spring I remember someone asked
> > Rasmus a question: which is more expensive, accessing a
> > global or defining
> > a constant? He said without hesitation "defining a constant."
>
>
> At that same conference I chatted with Zeev about this issue, too.  He
> concured, and said that defining a constant is more expensive than
> setting a variable.
>
> However, somehow I knew he wasn't telling the whole story, so I asked
> why... and why would anyone want a constant, aside from being static and
> globally scoped.
>
> He said that using constants, once defined, are less expensive than
> variables.  So I said... "hah, thought you'd say something like that..."
> :)


Heh! Which raises the question, then, how many times to you need to read a
constant to break even on that up-front expense, as it were, as compared
to a variable?

Maybe this is angels-on-the-head-of-a-pin stuff.


---
David Mintz
http://davidmintz.org/

        "Anybody else got a problem with Webistics?" -- Sopranos 24:17



More information about the talk mailing list