0
I don't understand the difference between equal and identical
Hey guys, Can you help me with my problem ? Thx for any answer ^^
7 ответов
+ 5
Basically an equal operator is more lenient on the datatypes, you can do a 3 == "3" and it will still output a true. But an identical operator is more strict, 3 === "3" will simply output a false. Meaning that in identical operator not only wants you to have a same value, it wants you to have a same datatype to output a true.
+ 4
It's pretty simple.
Let's say that you have three variables:
$a = 1
$b = "1"
$c = 1
== (equal) is used to determine if the variables have the same value.
=== (identical) is used to determine if the variables have the same value and same data type.
In this case you would use == (equal) to check if they have the same values.
So, $a == $c
But, $a is an Integer and $b is a string, so they're not identical because they're not the same data type and same value therefore $a !=== $b.
+ 1
"==" will check value of operator, "===" will check value and type. For example:
_______
1 == "1" --> true
1 === "1" --> false, because you compare int and String :)
+ 1
You are not right. Try to compile this:
if("1" == 1)
echo "true";
else
echo "false";
+ 1
As Wen Qin said. :-)
Read for more:
http://us3.php.net/manual/en/language.types.string.php#language.types.string.conversion
+ 1
hey frnd I haven't gone through the java so.....I m declining..
0
@Heroes Killer
1 == "1" would also return false because an Integer will never be equal to a string.