Category Archives: php-logical operator

PHP-Logical Operator

Logical Operators
Example Name Result
$a and $b And TRUE if both $a and $b are TRUE.
$a or $b Or TRUE if either $a or $b is TRUE.
$a xor $b Xor TRUE if either $a or $b is TRUE, but not both.
! $a Not TRUE if $a is not TRUE.
$a && $b And TRUE if both $a and $b are TRUE.
$a || $b Or TRUE if either $a or $b is TRUE.`

Check out this example

<?php
$a=TRUE; //1
$b=FALSE;//null 0
Echo “A has:”.(bool)$a;
echo”B has:”.(bool)$b;
echo “A AND B has: “;
echo $a && $b;
echo “A OR B has: “;
echo $a || $b;
?>