Share on Google+Share on Google+

Comparison Operators

This section contains the detail about Comparison Operator in PHP.

Comparison Operators

Operator is used to perform operation on variable and values. Comparison Operators are used to compare two values.

Given below the complete list of available comparison operator in PHP :

= = is equal to 5= =8 returns false
!= is not equal 5!=8 returns true
<> is not equal 5<>8 returns true
> is greater than 5>8 returns false
< is less than 5<8 returns true
>= is greater than or equal to 5>=8 returns false
<= is less than or equal to 5<=8 returns true

Given below example will give you a clear idea how to use comparison operator :

Example :


echo $a=$b ? "true\n" : "false\n";
echo "<br/>";
echo $b!=$c ? "true\n" : "false\n";
echo "<br/>";
echo $c>$a ? "true\n" : "false\n";


Output :



Posted on: February 4, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.