Pavel Pavel - 28 days ago 5x
PHP Question

PHP 5 to 7 migration - Numbers comparison

I noticed that code below results in different messages in PHP 5.x and 7:

if ('0xFF' == 255) {
echo 'Equal';
} else {
echo 'Not equal';

  • 5.x: Equal

  • 7: Not equal

Tried to find a description of the changes that cause it in migration guide and in the PHP doc but couldn't find anything. Probably it is somewhere there and I just missed it. Can you, please, point it? Thank you!

Where I looked


It's here:

Changes to String Handling

Hexadecimal strings are no longer considered numeric

Strings containing hexadecimal numbers are no longer considered to be numeric. For example: <?php var_dump("0x123" == "291"); etc...