php == vs === operator
How do the equality (== double equals) and identity (=== triple equals) comparison operators differ?
Why does the following statement return
"608E-4234" == "272E-3063"
I have also tried this with single quotes around the strings. The only way I can get it to evaulate to
false is by using the
=== operator instead of
My guess is PHP is treating it as some sort of equation but it seems a bit of a strange one.
Can anybody elaborate?
"608E-4234"is the float number format, so they will cast into number when they compares.
272E-3063will both be
float(0)because they are too small.
==is just same as
===, so type cast won't happen for compare with two same type values.
===to save one character.
typeofoperator always returns a string, so you could just use
typeof foo == 'string'instead of
typeof foo === 'string'with no harm.