note 87887 added to function.defined

From: Date: Mon, 29 Dec 2008 05:29:13 +0000
Subject: note 87887 added to function.defined
Groups: php.notes 
Request: Send a blank email to php-notes+get-148632@lists.php.net to get a copy of this message
@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. ---- Server IP: 92.48.74.199 Probable Submitter: 90.193.76.12 ---- Manual Page -- http://www.php.net/manual/en/function.defined.php Edit -- https://master.php.net/note/edit/87887 Del: integrated -- https://master.php.net/note/delete/87887/integrated Del: useless -- https://master.php.net/note/delete/87887/useless Del: bad code -- https://master.php.net/note/delete/87887/bad+code Del: spam -- https://master.php.net/note/delete/87887/spam Del: non-english -- https://master.php.net/note/delete/87887/non-english Del: in docs -- https://master.php.net/note/delete/87887/in+docs Del: other reasons-- https://master.php.net/note/delete/87887 Reject -- https://master.php.net/note/reject/87887 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148632) next »