Re: [PHP-DEV] [Fwd: [PHP] constant() - php5]

2005-07-01 Thread Nicholas Telford
Due to PHPs dynamic typing, unquoted strings are treated as strings unless a constant by that name exists. Thankfully it's clever enough to raise a notice to tell you it couldn't find a constant by that name, which makes debugging much easier. The reason constant() throws a warning rather than

Re: [PHP-DEV] [Fwd: [PHP] constant() - php5]

2005-07-01 Thread Jochem Maas
Derick Rethans wrote: On Fri, 1 Jul 2005, Jochem Maas wrote: echo constant('CNST'); when: echo CNST; only triggers an E_NOTICE. (assuming, in both cases that CNST is not defined). IMHO it should at most trigger an E_NOTICE. Did you compare the output of the two statements? I did. e

Re: [PHP-DEV] [Fwd: [PHP] constant() - php5]

2005-07-01 Thread Derick Rethans
On Fri, 1 Jul 2005, Jochem Maas wrote: > echo constant('CNST'); > > when: > > echo CNST; > > only triggers an E_NOTICE. > (assuming, in both cases that CNST is not defined). > > IMHO it should at most trigger an E_NOTICE. Did you compare the output of the two statements? echo constant('CNST'

Re: [PHP-DEV] [Fwd: [PHP] constant() - php5]

2005-07-01 Thread Jochem Maas
Pawel Bernat wrote: What is stupid with validating name before using it? its inconsistent to trigger an E_WARNING when doing: echo constant('CNST'); when: echo CNST; only triggers an E_NOTICE. (assuming, in both cases that CNST is not defined). IMHO it should at most trigger an E_NOTICE.

Re: [PHP-DEV] [Fwd: [PHP] constant() - php5]

2005-07-01 Thread Pawel Bernat
> > $cnst = "DEBUG"; > > // what I want to do but can't > if ($dbg = constant($cnst)) { > // do stuff > } > > // the only real option, it seems - bit long winded to get round a stupid > (IMHO) > if (defined($cnst) && ($dbg = constant($cnst))) { > // do stuff > } What is stupid with

[PHP-DEV] [Fwd: [PHP] constant() - php5]

2005-06-29 Thread Jochem Maas
hi, I just wanted to say about 'include' ... er no actually I have this little thing with constant() which I asked about on php-generals and the response from a couple of regulars suggest it might be a bug, or more correctly, an inconsistency. Jason Barnett wrote also: tested with PHP 5.0.5-dev