|
Posted by John Nichel on 11/14/98 11:22
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
Navigation:
[Reply to this message]
|