The PHP comparison operators(!=, ==)are used to compare two calues (number or string).
These operators are used to compare two elements and outputs the result in boolean form.
Operator | Name | Example | Result |
---|---|---|---|
== |
Equal | $x == $y |
True if $x is equal to $y |
=== |
Identical | $x === $y |
True if $x is equal to $y, and they are of the same type |
!= |
Not equal | $x != $y |
True if $x is not equal to $y |
<> |
Not equal | $x <> $y |
True if $x is not equal to $y |
!== |
Not identical | $x !== $y |
True if $x is not equal to $y, or they are not of the same type |
< |
Less than | $x < $y |
True if $x is less than $y |
> |
Greater than | $x > $y |
True if $x is greater than $y |
>= |
Greater than or equal to | $x >= $y |
True if $x is greater than or equal to $y |
<= |
Less than or equal to | $x <= $y |
True if $x is less than or equal to $y |
bool(true) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(false)