HOW TO USE COMPARISON OPERATORS IN PHP

PHP provides you with many comparison operators that you can use to compare values against each other. The most popular ones are: ==, >, <, >=, <=, != and are explained further below.

==

Use to test whether two values are equal in value.

Example:

if($name=='John')
{
echo "Welcome"; // any action statement/s
}

>

Use to test whether the left hand side value is greater in value than the right hand side value.

Example:

if($count > 10)
{
echo "Welcome"; // any action statement/s
}

<

Use to test whether the left hand side value is smaller in value than the right hand side value.

Example:

if($count < 10)
{
echo "Welcome"; // any action statement/s
}

>=

Use to test whether the left hand side value is greater than or equal to in value than the right hand side value.

Example:

if($count >= 10)
{
echo "Welcome"; // any action statement/s
}

<=

Use to test whether the left hand side value is smaller than or equal to in value than the right hand side value.

Example:

if($count <= 10)
{
echo "Welcome"; // any action statement/s
}

!=

Use to test whether the left hand side value is not equal to in value than the right hand side value.

Example:

if($count != 10)
{
echo "Welcome"; // any action statement/s
}