note 11017 deleted from function.define by sniper
| From: | sniper@php.net | Date: | Wed, 29 Jan 2003 04:02:23 +0000 |
| Subject: | note 11017 deleted from function.define by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42970@lists.php.net to get a copy of this message | ||
If you are using define() in a configuration file, and your script requires that the defined
constant be defined, check it! In other words, say you have a constant defined called HTML_BODY like
this:
define('HTML_BODY', '<body>');
In your PHP code that generates HTML you do this:
print(HTML_BODY);
However, if you fail to define HTML_BODY, or your client comments it out, this is the same as
saying:
print('HTML_BODY');
and the string of the constant name will be output. I consider this a bug, but it may be a feature.
Correctly dealing with constants that are optional (or not defined) could be done as follows:
if ( defined('HTML_BODY') && HTML_BODY ) print(HTML_BODY);