Hacker News new | ask | show | jobs
by guskel 30 days ago
PHP 8.3.6:

$ php -r 'var_dump("01234" == "1234");' bool(true)

$ php -r 'var_dump("09223372036854775808" == "9223372036854775808");' bool(false)

2 comments

If I show a person on the street a Fuji apple and a Honeycrisp and ask if they're approximately the same, they're going to say yes even if they're labeled.

Php has had a strict equals operator for decades. You not using it is not a language fault.

For the second point: I doubt you'll fine any language where you can just do an equals comparison on floats and it works as expected. That's the nature of floating point numbers.

For anyone wondering the number in the second example isn't just some random big number it's: PHP_INT_MAX + 1