PHP allows the use of boolean operators.
AND, OR, XOR and NOT. We can combine NOT with AND and OR to form the NAND and NOR operators respectively.
$a = ($b and $c); will return TRUE if both $b AND $c are TRUE, otherwise, it will return FALSE. This can also be specified as $a = ($b && $c)
$a = ($b or $c); will return TRUE if $b OR $c are TRUE, otherwise, it will return FALSE. This can also be specified as $a = ($b || $c);
$a = ($b xor $c); will return TRUE if $b OR $c are TRUE, but not if they are both TRUE, otherwise, it will return FALSE.
$a = (! $b); will return TRUE if $b is NOT TRUE.
$a = (!($b && $c)); will form NAND (NOT + AND)
$a = (!$b || $c)); will form NOR (NOT+AND);
(more…)
Tags: and, bool, boolean, logic, logical operators, nand, nor, or, PHP, php programmer, xor