note 31431 added to function.define
| From: | Ken at rack1 dot php dot net | Date: | Mon, 21 Apr 2003 18:46:44 +0000 |
| Subject: | note 31431 added to function.define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46904@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.
--
http://www.php.net/manual/en/function.define.php
http://master.php.net/manage/user-notes.php?action=edit+31431
http://master.php.net/manage/user-notes.php?action=delete+31431
http://master.php.net/manage/user-notes.php?action=reject+31431