PHP

Comparison Operators

About this snippet

This PHP code snippet is a conditional statement that compares two variables, $a and $b, and outputs a message based on their relationship:

A
B
Operator Description
== If the values of A and B are equal
!= If the values of A and B are not equal
> If the value of A is greater than the value of B
< If the value of A is less than the value B
>= If the value of A is greater than or equal to the value of B
<= If the value of A is less than or equal to the value of B
PHP
if ($a == $b ) {
echo "A and B are equal";
}

else if ($a > $b ) {
echo "A is greater than B";
}

else if ($a < $b ) {
echo "A is less than B";
}<