Top-5 Things that might bite you




For the full list see

php.net/migration70


Left-to-right semantics for complicated expressions


$$foo['bar']['baz'] // interpreted as ($$foo)['bar']['baz']
$foo->$bar['baz']   // interpreted as ($foo->$bar)['baz']
$foo->$bar['baz']() // interpreted as ($foo->$bar)['baz']()
Foo::$bar['baz']()  // interpreted as (Foo::$bar)['baz']()
To restore the previous behaviour add explicit curly braces:


${$foo['bar']['baz']}
$foo->{$bar['baz']}
$foo->{$bar['baz']}()
Foo::{$bar['baz']}()
Detection: phan or unit test failures


Removed support for /e (PREG_REPLACE_EVAL) modifier


echo preg_replace('//e', '$this->pres->\\1', $text);
Change to:


echo preg_replace_callback(
  '//', 
  function($matches) {
    return $this->pres->{$matches[1]}; // Careful!
  },
  $text);
Detection: grep, warnings in logs or unit test failures


$HTTP_RAW_POST_DATA global removed


if (empty($GLOBALS['HTTP_RAW_POST_DATA']) &&
    strpos($_SERVER['CONTENT_TYPE'], 'www-form-urlencoded') === false) {
    $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
}
Detection: grep, warnings in logs or unit test failures


session.lazy_write enabled by default

session.lazy_write = 0
Detection: Can cause out-of-band session read timing issues


Invalid octal literals now produce a parse error


echo 05678; // PHP 5.x outputs 375
Parse error: Invalid numeric literal in file.php on line 2
Detecting parse errors is easy: php -l