The comparison operators are used to compare two or more variables. Comparison itself is performed numerically, for instance if a string is compared to another string, both strings will be converted into a number.

List of comparison operators in PHP

List of comparison operators in PHP

Name

Example

Equal

$a == $b

Identical

$a === $b

Not equal

$a != $b

Not equal

$a <> $b

Not identical

$a !== $b

Less than

$a < $b

Greater than

$a > $b

Less than or equal to

$a <= $b

Greater than or equal to

$a >= $b

 

›› go to examples ››