php : Syntax of composite if statement
Operator Description
== Is equal to
=== Is identical to (is equal and is the same data type)
!= Is not equal to
!== Is not identical to
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
————————————————
Logical Operators in PHP
Operator Name Description
! a - NOT - True if a is not true
a && b AND - True if both a and b are true
a || b - OR - True if either a or b is true
a and b - AND - True if both a and b are true
a xor b - XOR - True if a or b is true, but not both
a or b - OR - True if either a or b is true
There are two different ways of performing a logical AND or OR in PHP. The difference between and and && (and between or and ||) is the precedence used to evaluate expressions.
Consider :
a or b and c
a || b and c
In the former condition, the and takes precedence and is evaluated first. The overall condition is true if a is true or if both b and c are true.
elseif Versus else if
In PHP you can also write elseif as two words: else if. The way PHP interprets this variation is slightly different, but its behavior is exactly the same.