Memory App
Php
 




AND

&& / and Evaluates to true if both the left and right operands evaluate to true.

if (isset($a) AND isset($b)) {
    // a and b is set
}
(1/3)

OR

|| / or Evaluates to true if either the left or right operands evaluate to true.

if (isset($a) OR isset($b)) {
    // a, b, a and b - could be set
}
(2/3)

XOR

Evaluates to true if either the left and right operands evaluates to true, but not both.

$a = "1";
$b = "abc";

if (is_numeric($a) XOR is_numeric($b)) {
    echo "Only one number exists";
}
// Outputs: Only one number exists
It's important to understand that all logical operators only work with Boolean values. PHP will first convert any other value to a Boolean and then perform the operation.
Questions










Top Reference > Programming