PHP - Using Logical operators


Logical operators apply a logic operation to its operands, returning a Boolean response.

The most used ones are ! (not), && (and), and || (or).

&& will return true only if both operands evaluate to true.

|| will return true if any or both of the operands are true.

! will return the negated value of the operand, that is, true if the operand is false or false if the operand is true.


    var_dump(true && true); // true 
    var_dump(true && false); // false 
    var_dump(true || false); // true 
    var_dump(false || false); // false 
    var_dump(!false); // true 
?>/*w  w w  .j  a  v  a  2 s  . c  o  m*/


Related Topic