PHP logical operators true false

The &&  and ||  logical operators seem to have more general recognition and background usage, although the and  and or  form of the same logical operators is taking more and more acceptation for the sake of readability.

So here is a list for the results when evaluating the expressions in PHP. I am sure that this can be applied to a bunch of other languages. (I think it is a little bit superficial to say that it apply to all programming language since I only know some of them).

Logical operator AND  (&& )

false and false => false

false and true => false

true and false => false

true and true => true

 

Logical operator OR  (|| )

false or false => false

false or true => true

true or false => true

true or true => true

 

Logical operator NOT  (! )

!false => true

!true => false

 

Leave a Reply

Your email address will not be published. Required fields are marked *