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

From: Date: Wed, 29 Jun 2005 23:00:57 +0000
Subject: [Fwd: [PHP] constant() - php5]
Groups: php.internals 
Request: Send a blank email to internals+get-17019@lists.php.net to get a copy of this message
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 <?php /* Causes E_WARNING */ echo "constant('UNDEFINED_CONSTANT')\n"; echo constant('UNDEFINED_CONSTANT'); /* Causes E_NOTICE */ echo "UNDEFINED_CONSTANT\n"; echo UNDEFINED_CONSTANT; ?>
should(may) I submit a bugreport? -------- Original Message -------- anybody here know what the logic is behind constant() triggering a warning if the named constant is not found? contrived example: <? $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 } PLEASE - nobody need bother to tell me about the @ operator, I am aware of it but I don't want to use it in this case. (addition: not for a warning) thanks & rgds, jochem

« previous php.internals (#17019) next »