从PHP 7.0.x 移植到 PHP 7.1.x
PHP Manual

不向后兼容的变更

当传递参数过少时将抛出错误

在过去如果我们调用一个用户定义的函数时,提供的参数不足,那么将会产生一个警告(warning)。 现在,这个警告被提升为一个错误异常(Error exception)。这个变更仅对用户定义的函数生效, 并不包含内置函数。例如:

<?php
function test($param){}
test();

Output of the above example in PHP 5.5:

Uncaught Error: Too few arguments to function test(), 0 passed in %s on line %d and exactly 1 expected in %s:%d

Forbid dynamic calls to scope introspection functions

Dynamic calls for certain functions have been forbidden (in the form of $func() or array_map('extract', ...), etc). These functions either inspect or modify another scope, and present with them ambiguous and unreliable behavior. The functions are as follows:

<?php
(function () {
    
'func_num_args'();
})();

以上例程会输出:

Warning: Cannot call func_num_args() dynamically in %s on line %d

Invalid class, interface, and trait names

The following names cannot be used to name classes, interfaces, or traits:

Numerical string conversions now respect scientific notation

Integer operations and conversions on numerical strings now respect scientific notation. This also includes the (int) cast operation, and the following functions: intval() (where the base is 10), settype(), decbin(), decoct(), and dechex().

Fixes to mt_rand() algorithm

mt_rand() will now default to using the fixed version of the Mersenne Twister algorithm. If deterministic output from mt_srand() was relied upon, then the MT_RAND_PHP with the ability to preserve the old (incorrect) implementation via an additional optional second parameter to mt_srand().

rand() aliased to mt_rand() and srand() aliased to mt_srand()

rand() and srand() have now been made aliases to mt_rand() and mt_srand(), respectively. This means that the output for the following functions have changes: rand(), shuffle(), str_shuffle(), and array_rand().

Disallow the ASCII delete control character in identifiers

The ASCII delete control character (0x7F) can no longer be used in identifiers that are not quoted.

error_log changes with syslog value

If the error_log ini setting is set to syslog, the PHP error levels are mapped to the syslog error levels. This brings finer differentiation in the error logs in contrary to the previous approach where all the errors are logged with the notice level only.

在不完整的对象上不再调用析构方法

析构方法在一个不完整的对象(例如在构造方法中抛出一个异常)上将不再会被调用。

call_user_func()不再支持对传址的函数的调用

call_user_func() 现在在调用一个以引用作为参数的函数时将始终失败。

字符串不再支持空索引操作符 The empty index operator is not supported for strings anymore

对字符串使用一个空索引操作符(例如$str[] = $x)将会抛出一个致命错误, 而不是静默地将其转为一个数组。

ini配置项移除

下列ini配置项已经被移除:


从PHP 7.0.x 移植到 PHP 7.1.x
PHP Manual