1. Computing

Discuss in my forum

Using Comparison Operators in PHP

By , About.com Guide

You can use PHP code to compare two numbers and then make a decision based on if the condition is true or false. Here are the comparisons that you can use:

> (greater than)
< (less than)
== (equal to)
!= (not equal to)
<= (Less Than or Equal To)
>= (Greater Than or Equal To)

Here is an example of how to use an operator to make a decision in combination with the if () function.

<?php
if ($x > $y)
{
echo "x is greater than y";
}
elseif ($x == $y)
{
echo "x is equal to y";
}
else
{
echo "x is smaller than y";
}
?>

Related Video
Basic PHP Syntax
Using PHP With HTML
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn PHP
  5. Comparing with PHP - PHP Comparison Operators

©2013 About.com. All rights reserved.