note 35922 modified in function.constant by vrana

From: Date: Tue, 17 Aug 2004 14:55:12 +0000
Subject: note 35922 modified in function.constant by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79880@lists.php.net to get a copy of this message
Hello. This applies to constants being defined as Boolean values, and may-be applies generally. I advise you to NOT use this in an included file, in a function or elsewhere outside the scope where the define('TRACE',TRUE) is placed) : if (TRACE) {} This will always evaluate to TRUE if the constant is not defined previously (the story about this becoming an string 'TRACE', thus evaluating to TRUE) Use this : <?php if ((defined('TRACE'))AND(constant('TRACE'))) {} ?> --was-- Hello. This applies to constants being defined as Boolean values, and may-be applies generally. I advise you to NOT use this in an included file, in a function or elsewhere outside the scope where the define('TRACE',TRUE) is placed) : if (TRACE) {} This will always evaluate to TRUE if the constant is not defined previously (the story about this becoming an string 'TRACE', thus evaluating to TRUE) Use this : if ((defined('TRACE'))AND(constant('TRACE'))) {} http://php.net/manual/en/function.constant.php

« previous php.notes (#79880) next »