Re: PHP boolean's
- From: Michael Sharman <sharmo@xxxxxxxxx>
- Date: Fri, 30 May 2008 19:07:04 -0700 (PDT)
On May 31, 11:57 am, petersprc <peters...@xxxxxxxxx> wrote:
The not operator (!) has higher precedence and is evaluated prior to
the mod operator.
You can use: if ($count % 2 == 0)
Precedence list:
http://us.php.net/manual/en/language.operators.php#language.operators...
As for your other question about boolean comparisons, here are the
rules on boolean conversion:
http://us2.php.net/manual/en/language.types.boolean.php#language.type...
Regards,
John Peters
On May 30, 9:38 pm, Michael Sharman <sha...@xxxxxxxxx> wrote:
Can anyone confirm if in PHP 0 = FALSE and anything else if TRUE?
Or is it more 0 = FALSE and 1 = TRUE?
One of the reasons I ask is that if I do;
//$count is an incrementing value starting from 0 in a loop
if($count % 2)
{
//do something
}
This works fine, but if I do:
if(!$count % 2)
{
//do something
}
It doesn't work. Should it not just be a boolean comparison? Why do I
need to do this to get my FALSE?
if($count % 2 === 0)
{
}
Thanks for that John.
I suppose I can also do;
if(!($count % 2))
.
- Follow-Ups:
- Re: PHP boolean's
- From: Michael Fesser
- Re: PHP boolean's
- References:
- PHP boolean's
- From: Michael Sharman
- Re: PHP boolean's
- From: petersprc
- PHP boolean's
- Prev by Date: Re: include 'filename.php' vs. exit 'whatever'
- Next by Date: Re: sessions being destroyed prematurely
- Previous by thread: Re: PHP boolean's
- Next by thread: Re: PHP boolean's
- Index(es):