There are several operators used in PHP to carry out programming operations.
=
is the assignment operator, this assigns a value
e.g $x = 'hello world
==
is the equality operator , it is used to test for equality
<?php
$day = "Monday";
if ($day == "Monday") echo "It is work day"
?>
Since $day = Monday
and satisfies the condition, we have the output - It is work day
===
is the identity operator that is use to test if they are equal and of the same type
<?php
$a = "1000";
$b = 1000;
if ($a === $b)
{
echo "identical" ;
}
else
{
echo "not identical"
}
?>
outputs not identical because $a
is a string and $b
is numerical, in other words they are of different type.
Top comments (0)