I was reading an article and I found this example:
// Prints bool(true)
var_dump('9223372036854775807' == '9223372036854775808');
// Prints bool(false)
var_dump('9223372036854775807' ==='9223372036854775808');
Anyone can explain me why?
I was reading an article and I found this example:
// Prints bool(true)
var_dump('9223372036854775807' == '9223372036854775808');
// Prints bool(false)
var_dump('9223372036854775807' ==='9223372036854775808');
Anyone can explain me why?
As of PHP 5.4.4 this is no longer an issue.
The reason why this is happening, is because of type-juggling. In the first example you're checking if the two values are equal AFTER type-juggling so effectively it's comparing two string types.
And in the other example you are checking whether the two values are identical, as in the same type and the exact same value.
Check this.