Logical Operators

Logical Operators

There are following logical operators supported by PHP language

Assume variable A holds 10 and variable B holds 20 then −

Show Examples

OperatorDescriptionExample
andCalled Logical AND operator. If both the operands are true then condition becomes true.(A and B) is true.
orCalled Logical OR Operator. If any of the two operands are non zero then condition becomes true.(A or B) is true.
&&Called Logical AND operator. If both the operands are non zero then condition becomes true.(A && B) is true.
||Called Logical OR Operator. If any of the two operands are non zero then condition becomes true.(A || B) is true.
!Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.!(A && B) is false.