The logical operators are used to evaluate Boolean result of two or more logical comparison. The conditional expressions sometimes may require a logical operator.

The logical operators are represented by the list below:

Example of logical operators in PHP

<?php
    $a = (false && func());  // AND operator
    $a = (true || func());   // OR operator
    $a = (false and func()); // AND operator
    $a = (true or func());   // OR operator
    $a xor $b;              // XOR operator - true if either variable is true
    !$a;                    // NOT operator - true if variable is NOT true  
?>

 

›› go to examples ››