Web EndMemo

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:
Symbol Definition
== equal to
=== identical to
!= not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to
and (&&) whether two conditions are both satisfied
or (||) whether one of the conditions is satisfied
xor If both conditions are satisfied, return false
! if not satisfy the condition, return true