DEV Community

Andrej Rypo
Andrej Rypo

Posted on

php 8 fun

From all of the breaking changes introduced in PHP 8 I think the change to the comparison operator is the most intricate one:

// To be `true` or not to be? That is the question.
'' == 0
'' === 0
'0' == 0
'💩' == 0
'0foo' == 0
Enter fullscreen mode Exit fullscreen mode

See the difference of evaluation in PHP 7 and PHP 8 here:

I just don't understand how it's possible that I have not encountered a bug because of it yet.

Hopefully, no sensible person is using the equality == operator.

Discussion (0)