Re: PHP boolean's



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))
.