Re: define (true/false)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux