I did a few tests with strings using '=='. I know to compare strings using '==' is not the way, but there is a weird behavior I want to solve.
I'm following the PHP documentation on page Comparison Operators. This is the test I did:
<?php
var_dump( "100" == "1e2" ); // Outputs boolean true
var_dump( (int) "100" ); // int 100
var_dump( (int) "1e2" ); // int 1
?>
The documentation says when we compare strings with numbers, PHP first converts the string to numbers, but when I convert '100' and '1e2' to numbers they are not equal. The comparison should outputs boolean false.
Why is this weird behavior?
===instead of==, since the result is far more predictable!===)? What is the canonical Stack Overflow question for it?