On Wed, August 22, 2007 8:03 am, Dmitry Stogov wrote:
> You can have "const" outside namespaces but they are not real
> compile-time
> constants.
> They are set during execution in the same way as define() does.
>
> <?php
> const DIR = dirname(__FILE__);
> echo DIR;
> ?>

You do realize this is going to engender a few zillion threads on
PHP-General benchmarking the two and endless arguments about which is
faster/better...

<?php
  const DIR = dirname(__FILE__);
  define(DIR, dirname(__FILE__);
?>

I personally find it kinda silly to have TWO syntaxes for defining
constants in the global space, one of which looks like a declarative
statement in C, which will lead to a whole new swath of arguments
about what is "better"

Why is 'define' any different than 'class' or 'function'?

Seems to me that if you want these namespace thingies that badly, then
'define' should follow the same rules as any other declarative
keyword.

If you 'define' something in the namespace, it's in the namespace.

If you want global scope, 'define' it outside a namespace and be done
with it.

Seems to me you're just complicating things with no real-world need
here...

What are your real-world "I need this because..." code samples?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to