Re: define (true/false)

From: Date: Thu, 28 Jul 2005 13:03:18 +0000
Subject: Re: define (true/false)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-219498@lists.php.net to get a copy of this message
Sebastian wrote:
i never really used constants before so this may sound stupid.. when you define a constant using define() and want to return true/false is this logical: if($bars == 3) { define('BAR', 1); } then: if(BAR) { // bars is true } or should i need to do an else statement as well: if($bars == 3) { define('BAR', 1); } else { define('BAR', 0) } lastly is it more practical to just do: if($bars == 3) {
     $bar = true;
} i am curious what most people would use.
I wouldn't use a constant for that, but in either case, I'd do the else and define it either way. If your statement doesn't evaluate to true and you don't define your variable/constant, you'll get a notice (if you have that level of error reporting turned on) when you try to check it. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#219498) next »