note 31431 deleted from function.define by spic
| From: | spic@php.net | Date: | Mon, 21 Apr 2003 18:50:17 +0000 |
| Subject: | note 31431 deleted from function.define by spic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-46905@lists.php.net to get a copy of this message | ||
Constants CAN be redefined (kinda sorta) so watch out for this:
<?php
define ("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
define ("CONSTANT", "My world.", true);
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "My world."
echo constant; // outputs "My world."
?>
If a case-sensentive constant exists, redefining it as case-insensitive will produce no warning, all
alternative case combinations will contain the new value and the original case spelling will contain
the old. In a large complicated script, it may be best to check if a constant has already been
defined and not rely on the rule that it can't be redefined.