Mega Code Archive
Logical Operators
Operator Name Returns True if... Example Result
|| Or Left or right is true true || false true
or Or Left or right is true true || false true
xor Xor Left or right is true but not both true xor true false
&& And Left and right are true true && false false
and And Left and right are true true && false false
! Not The single operand is not true ! true false
";
$result .= "OR - 1:$test4 2:$test5 3:$test6
";
$result .= "XOR - 1:$test7 2:$test8 3:$test9
";
$result .= "NOT - 1:$test10 2:$test11";
echo( $result );
?>
$age = 20;
if (($age >= 13) && ($age < 65)) {
print "too old for a kid's discount and too young for the senior's discount.";
}
$meal = 'breakfast';
if (($meal == 'breakfast') || ($dessert == 'souffle')) {
print "Time to eat some eggs.";
}
?>