Logical Operators in PHP programming

Logical Operators are using for comparing between Boolean values and will return a Boolean result. Boolean values are TRUE and FALSE.

And Operator : and
Usage : ( $x and $y ), It will return TRUE if both $x and $y are TRUE, otherwise it will return FALSE.

Or Operator : or
Usage : ( $x or $y ). It will return TRUE if $x or $y is TRUE, otherwise it will return FALSE

Xor Operator : xor
Usage : ( $x xor $y ) , It will return TRUE if either $x or $y is TRUE, but both should not be TRUE. It will return FALSE if both are TRUE or FALSE.

Not Operator : !
usage ( !$x) , It will return TRUE if $x is not TRUE

And Operator : &&
Usage : ( $x && $y ), It will return TRUE if both $x and $y are TRUE, otherwise it will return FALSE.

Or Operator : ||
Usage : ( $x || $y ). It will return TRUE if $x or $y is TRUE, otherwise it will return FALSE

Here we can see that two operators are for And Operator ( and , && )
and
two operators are for Or Operator ( or, || ).
Both will do the same job.

Share
Share
Share