Home Tutorial Php Phpbeginners Comparison Operators

 
 

Comparison Operators
Posted on: February 4, 2011 at 12:00 AM
Advertisement
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 :

OPERATOR NAME EXAMPLE
= = 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 :

<?php
$a=3;
$b=21;
$c=30;

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 :

true
true
true

Advertisement

Related Tags for Comparison Operators:


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.

Posted on: February 4, 2011

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com