Welcome
    

Comparison operators

 

 

 

 

Comparison operators in PHP are used to compare two values and return a boolean result (true or false) based on the comparison. Here are the comparison operators supported in PHP:

 

 

Equal (==)

 

 

Checks if two values are equal.

 

 

$x == $y; // true if $x is equal to $y

 

 

Identical (===)

 

 

Checks if two values are equal and of the same data type.

 

 

$x === $y; // true if $x is equal to $y, and they are of the same data type

 

 

Not equal (!=) or Not identical (!==)

 

 

Checks if two values are not equal or not of the same data type, respectively.

 

 

$x != $y; // true if $x is not equal to $y
$x !== $y; // true if $x is not equal to $y, or they are not of the same data type

 

 

Greater than (>)

 

 

Checks if the left operand is greater than the right operand.

 

 

$x > $y; // true if $x is greater than $y

 

 

Less than (<)

 

 

Checks if the left operand is less than the right operand.

 

 

$x < $y; // true if $x is less than $y