Logical Operators

Logical operators applies four logical functions to booleans.

  • and and &&

  • or and ||

  • xor, no symbolic version for xor

  • !, no letter version for not

The logical operators are either symbolic or letter. Be aware that the symbolic operators have a higher precedence than the letter one, in particular in regards to comparisons.

The logical operators work on various types, and output booleans. They are different from the bitwise operators, which work on the value as a bit level, not as a whole.

<?php

    if ($a == $b) {
        print "a and b are equal";
    }

?>

Documentation

See also Operator Precedence.

Related : Bitwise Operators, Not Operator, And Operator, Bitshift Operators, False, True, Letter Logical Bug, Pipe Operator