Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 5 to 7 migration - Numbers comparison

Tags:

php

php-7

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

  • http://php.net/manual/en/migration70.php
  • http://php.net/manual/en/language.types.type-juggling.php
  • http://php.net/manual/en/language.operators.comparison.php
like image 986
Pavel Avatar asked Sep 26 '16 18:09

Pavel


People also ask

Is PHP 5 faster than 7?

The PHP development team released the latest version of PHP: PHP 7 claiming it to be twice as fast as its predecessor PHP 5.

What is the main difference between PHP 5 and PHP 7?

PHP is powered by Zend Engine even since the release of PHP 4. PHP 5 uses Zend II but PHP 7 uses a brand new model of engine called PHPNG or Next Generation. This new PHPNG engine improves the performance as much as twice with optimized memory usage. This has been proved by the benchmark provided by the company.

Why PHP 7 is faster?

Why PHP 7 is faster? PHP 7 runs on the PHPNG engine (or Zend Engine 3.0) that speeds up PHP apps more than the previous PHP interpreter (Zend Engine 2.0). Thanks to PHPNG, your applications will perform 2x faster and has 50% better memory consumption than PHP 5.6.

What are the most important advantages of using PHP 7 over PHP 5?

Upgrading to PHP7 not only ensures fast website loading but also far efficient scripting that runs flawlessly every time users access the website. Therefore, if businesses choose to upgrade their websites from PHP5 to PHP7, it would be beneficial for their businesses to grow.


1 Answers

It's here: http://php.net/manual/en/migration70.incompatible.php

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...

like image 172
Marc B Avatar answered Sep 29 '22 09:09

Marc B