PHP IF Else
if() {...} else if () {...} else {...} check conditions, and then execute commands that satisfy the condition.
<?PHP
$sum=0;
$sum2=0;
$sum3=0;
for($ii=0;$ii<100;$ii++)
{
if ($ii % 2 == 0)
{
$sum2 += $ii;
}
else if ($ii % 3 == 0)
{
$sum3 += $ii;
}
else
{
$sum += $ii;
}
}
?>
PHP operators for comparison:
>=
greater than or equal to
and
whether two conditions are both satisfied
&&
whether two conditions are both satisfied, has higher operator precedence than "and"
or
whether one of the conditions is satisfied
||
whether one of the conditions is satisfied, has higher operator precedence than "or"
xor
If both conditions are satisfied, return false
!
if not satisfy the condition, return true