note 114426 deleted from function.define by cmb

From: Date: Sun, 06 Oct 2019 07:51:21 +0000
Subject: note 114426 deleted from function.define by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212473@lists.php.net to get a copy of this message
Note Submitter: daevid at daevid dot com ---- Be aware that undefined constants are not evaluated the same as undefined variables (which is frustratingly counter-intuitive)... $ php -a php > if (!DO_IT) echo "don't do it\n"; else echo "do it\n"; do it php > var_dump(DO_IT); string(5) "DO_IT" php > if (!$DO_IT) echo "don't do it\n"; else echo "do it\n"; don't do it php > var_dump($DO_IT); NULL You have to specifically check for the definition like so... php > if(!defined('DO_IT') || (defined('DO_IT') && !DO_IT))echo "don't do it\n"; else echo "do it\n"; don't do it *sigh*

« previous php.notes (#212473) next »