You are here: Re: [PHP] define (true/false) « PHP « IT news, forums, messages
Re: [PHP] define (true/false)

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация