Processing: chap_01_php5_to_php7_code_converter_test_file.php <% date_default_timezone_set('Europe/Berlin'); function myErrorHandler($errno, $errstr, $errfile, $errline) { // some code } // WARNING: might not catch all errors // see: http://php.net/manual/en/language.errors.php7.php $old_error_handler = set_error_handler("myErrorHandler"); $php5 = 'Works in PHP 5'; $foo = ['bar' => ['baz' => 'php5']]; // WARNING: variable interpolation now occurs left-to-right // see: http://php.net/manual/en/migration70.incompatible.php echo $$foo['bar']['baz']; echo PHP_EOL; // WARNING: changes have been made in how the list() operator is handled // see: http://php.net/manual/en/migration70.incompatible.php list() = $a; // WARNING: \u{xxx} is now considered unicode escape syntax // see: http://php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax echo '\u{xxx} has a special meaning in PHP 7'; echo PHP_EOL; // WARNING: negative and out-of-range bitwise shift operations will now throw an ArithmeticError // see: http://php.net/manual/en/migration70.incompatible.php try { var_dump(1 << -1); } catch (\ArithmeticError $e) { error_log("File:" . $e->getFile() . " Line:" . $e->getLine() . " Message:" . $e->getMessage()); } echo PHP_EOL; // WARNING: negative and out-of-range bitwise shift operations will now throw an ArithmeticError // see: http://php.net/manual/en/migration70.incompatible.php try { var_dump(1 >> 65); } catch (\ArithmeticError $e) { error_log("File:" . $e->getFile() . " Line:" . $e->getLine() . " Message:" . $e->getMessage()); } echo PHP_EOL; $now = new DateTime(); // WARNING: call_user_method_array() has been removed from PHP 7 call_user_func_array([$now,'setDate'], array(2016, 11, 11)); // WARNING: call_user_method_array() has been removed from PHP 7 call_user_func_array([$now,'setTime'], array(11, 11, 11)); echo // WARNING: call_user_method() has been removed from PHP 7 call_user_func([$now,'format'], 'Y-m-d H:i:s'); echo PHP_EOL; $ids = 'Alice = 1, Dick = 33, Jane = 102, Fred = 88'; // WARNING: preg_replace() "/e" modifier has been removed from PHP 7 echo preg_replace_callback('/([0-9]{1,3})/',function ($m) { return echo sprintf("%03d",$m); }, $ids); echo PHP_EOL; ?>