Comparison Operators in PHP

Operator            Definition
==                     Equal to
!=                      Not equal to
>                       Greater than
<                       Less than
>=                     Greater than or equal to
<=                     Less than or equal to

<TITLE>Using Comparison Operators</TITLE>
$a = 21;
$b = 15;
echo “<P>Original value of $a is $a and $b is $b</P>”;
if ($a == $b) {
echo “<P>TEST 1: $a equals $b</P>”;
} else {
echo “<P>TEST 1: $a is not equal to $b</P>”;
if ($a != $b) {
echo “<P>TEST 2: $a is not equal to $b</P>”;
} else {
echo “<P>TEST 2: $a is equal to $b</P>”;
if ($a > $b) {
echo “<P>TEST 3: $a is greater than $b</P>”;
} else {
echo “<P>TEST 3: $a is not greater than $b</P>”;
if ($a < $b) {
echo “<P>TEST 4: $a is less than $b</P>”;
} else {
echo “<P>TEST 4: $a is not less than $b</P>”;
if ($a >= $b) {
echo “<P>TEST 5: $a is greater than or equal to $b</P>”;
} else {
echo “<P>TEST 5: $a is not greater than or equal to $b</P>”;
if ($a <= $b) {
echo “<P>TEST 6: $a is less than or equal to $b</P>”;
} else {
echo “<P>TEST 6: $a is not less than or equal to $b</P>”;

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published. Required fields are marked *