I did some string tests using '=='. I know that comparing the string '==' is wrong, but there is a strange behavior that I want to solve.
I follow the PHP documentation on this page: http://www.php.net/manual/en/language.operators.comparison.php . This is the test I did.
<?php
var_dump( "100" == "1e2" );
var_dump( (int) "100" );
var_dump( (int) "1e2" );
?>
The documentation says that 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 output a boolean false.
Why is this weird behavior? Thank!
source
share