PHP comparison operators

PHP comparison operator means using PHP operators compare two things or two variable. Suppose that we have two variable $a=10 and $b=20. We have to know which variable is small or big. In that case we use comparison operators. Different types of PHP comparison operators are given below

( == ) Equal : It returns true if $a and $b is same. 
( != ) Not Equal : It returns true if $a and $b is not same. 
( === ) Identical : It returns true when $a and $b is same and same type. 
( !== ) Not Identical : It returns true when $a and $b is not same and same type.
( < ) Less than : Returns true if ($a<$b) $a is less than $b. 
( > ) Greater than : Returns true if ($a<$b) $a is greater than $b. 

PHP comparison operators first check the condition then return true or false. If true then execute the program otherwise not execute the program.

Now take a look at the example below
<pre class=”brush: php;”>
<?php
$a
=10;
$b
=20;
$c
=10;
echo
($a==$c);
echo
"<br>";
echo
($a===$c);
echo
"<br>";
echo
($a!=$b);
echo
"<br>";
echo
($a!==$b);
echo
"<br>";
echo
($a<$b);
echo
"<br>";
echo
($b>$c);
?>
</pre>

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database