php-comparision operator

Comparisons are used to check the relationship between variables and/or values. Comparison operators are used inside conditional statements and evaluate to either true or false. Here are the most important comparison operators of PHP.

Operator Desc Example Result
== Equal To $x == $y false
!= Not Equal To $x != $y true
< Less Than $x < $y true
> Greater Than $x > $y false
<= Less Than or Equal To $x <= $y true
>= Greater Than or Equal To $x >= $y false

Check out this example:

<?php
$a=10;
$b=17;
/*
$a=17;
$b=10;
*/
echo  “<br>A is : “.$a;
echo  “<br>B is : “.$b;
echo “<br><br>”;
if($a==$b)
{
echo”<br>A equals B.”;//it wont be true
}
if($a != $b){
echo  “<br>A is not equals to B.”;//it will be true
}
if($a < $b){
echo  “<br>A is less than B;”;
}
if($a > $b){
echo  “<br>A is greater than B;”;
}
if($a <= $b){
echo  “<br>A is less than or equals to B;”;
}
if($a >= $b){
echo “<br>A is greater than or equals to B;”;
}
?>