note 87887 deleted from function.defined by danbrown

From: Date: Fri, 30 Jan 2009 21:34:16 +0000
Subject: note 87887 deleted from function.defined by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150014@lists.php.net to get a copy of this message
Note Submitter: seth36 at gmail dot com ---- @reachmike at hotpop dot com: First off the reason for the error showing dependant on error level is because references to undefined constants throw an error level of Notice, so you will need E_ALL or the inclusion of E_NOTICE in your error_reporting mode to see the error message. As for the constant name TEST being output, in your code example you use <?= TEST ?> which is a shorthand for <?php echo TEST ?>, meaning you want to output the value of the constant on the page, however as the constant is not defined PHP is assuming you meant to use the string "TEST" as oppossed to a non-existant constant, and thus prints the string "TEST" onto the page. You can easily solve your "just output a blank string if the constant doesn't exist" scenario using the constant() function: <?= constant("TEST") ?> This will work as you want, if the constant is defined, it's value will be output, otherwise an error level of E_WARNING will be thrown and a the constant name will not be output.

« previous php.notes (#150014) next »