28 Jan 2014

OPERATORS IN PHP :- Comparison Operators

PHP comparison operators allow you to compare two values against each other.The comparison is read from left to right by the PHP engine. Widely use in Conditional Logic and Control Structures.

  1. Equal    :- $var1 == $var2  Result :- TRUE if $var1 is equal to $var2.
  2. Identical    :- $var1 === $var2  Result :- TRUE if $var1 is equal to $var2, and they are of the same type
  3. Not Equal    :- $var1 != $var2 Result :- TRUE if $var1 is not equal to $var2
  4. Not Equal    :- $var1 < > $var2  Result :- TRUE if $var1 is not equal to $var2.
  5. Not Identical    :- $var1 !== $var2  Result :- TRUE if $var1 is not equal to $var2, or they are not the same type.
  6. Less Than    :- $var1 < $var2   Result :- TRUE if $var1 is strictly less than $var2.
  7. Greater Than    :- $var1 > $var2   Result :- TRUE if $var1 is strictly greater than $var2.
  8. Less Than or Equal to    :- $var1 <= $var2   Result :- TRUE if $var1 is less than or equal to $var2.
  9. Greater Than or Equal to    :- $var1 >= $var2   Result :- TRUE if $var1 is greater than or equal to $var2.
 example