This version brings an important changes with the directive zend.exception_ignore_args set to On by default.
In all stack traces, the args key is now missing.
All php frameworks have to handle this to report errors & exceptions.
为 array_key_exists() 函数添加了一个专门的 VM opcache
优化,如果该函数可以被静态解析,则可以提高该函数的性能。如果你在项目中使用了命名空间,可能会需要使用
\array_key_exists()
来显性的导入该函数。
When preg_match() in UTF-8 mode ("u"
modifier)
is repeatedly called on the same string (but possibly different offsets),
it will only be checked for UTF-8 validity once.
zend.exception_ignore_args is a new INI directive for including or excluding arguments from stack traces generated from exceptions.
opcache.preload_user is a new INI directive for specifying the user account under which preloading code is execute if it would otherwise be run as root (which is not allowed for security reasons).
一些扩展已经迁移到只使用 pkg-config 来检测库的依赖性。一般来说,这意味着不再用
--with-foo-dir=DIR 或类似的参数,而是使用
--with-foo。自定义库的路径可以通过向 PKG_CONFIG_PATH
添加额外的目录,或通过 FOO_CFLAGS
和 FOO_LIBS
来明确指定。
以下扩展和 SAPI 会受到影响:
现在 fputcsv()、fgetcsv()、SplFileObject::fputcsv()、SplFileObject::fgetcsv()
和 SplFileObject::setCsvControl() 的 $escape
参数 接受空字符,这会禁用 PHP 专有的转义机制。
str_getcsv() 的行为已相应调整(之前空字符串与使用默认值相同)。
SplFileObject::getCsvControl() 也可以相应的为第三个数组元素返回空字符串。
The filter extension no longer exposes --with-pcre-dir for Unix builds and can now reliably be built as shared when using ./configure
The behavior of imagecropauto() in the bundled libgd has been synced with that of system libgd:
IMG_CROP_DEFAULT
is no longer falling
back to IMG_CROP_SIDES
The default $mode
parameter of
imagecropauto() has been changed to
IMG_CROP_DEFAULT
; passing -1
is now deprecated.
imagescale() now supports aspect ratio preserving
scaling to a fixed height by passing -1
as $new_width
.
The hash extension cannot be disabled anymore and is always an integral part of any PHP build, similar to the date extension.
移除对 nsldap 和 umich_ldap 的支持。
All libxml-based extensions now require libxml 2.7.6 or newer.
The oniguruma library is no longer bundled with PHP, instead libonig needs to be available on the system. Alternatively --disable-mbregex can be used to disable the mbregex component.
The --disable-opcache-file and --enable-opcache-file configure options have been removed in favor of the opcache.file_cache INI directive.
现在 password_hash() 和 password_needs_rehash()
函数接受可以为 null 的字符串和 int 作为 $algo
参数。
Installation of PEAR (including PECL) is no longer enabled by default. It can be explicitly enabled using --with-pear. This option is deprecated and may be removed in the future.
The numeric values of the modifier constants
(IS_ABSTRACT
,
IS_DEPRECATED
,
IS_EXPLICIT_ABSTRACT
,
IS_FINAL
,
IS_IMPLICIT_ABSTRACT
,
IS_PRIVATE
,
IS_PROTECTED
,
IS_PUBLIC
, and
IS_STATIC
) on the
ReflectionClass,
ReflectionFunction,
ReflectionMethod,
ReflectionObject, and
ReflectionProperty
classes have changed.
SimpleXMLElement now implements Countable.
The bundled libsqlite has been removed. To build the SQLite3 extension a system libsqlite3 ≥ 3.7.4 is now required. To build the PDO_SQLite extension a system libsqlite3 ≥ 3.5.0 is now required.
Serialization and unserialization of SQLite3, SQLite3Stmt and SQLite3Result is now explicitly forbidden. Formerly, serialization of instances of these classes was possible, but unserialization yielded unusable objects.
The @param
notation can now also be used to
denote SQL query parameters.
The bundled libzip library has been removed. A system libzip >= 0.11 is now necessary to build the zip extension.
This version brings an important changes with the directive zend.exception_ignore_args set to On by default.
In all stack traces, the args key is now missing.
All php frameworks have to handle this to report errors & exceptions.
As of PHP 7.4, an exception thrown within the user-defined shutdown function can be caught by the user-defined exception handler.
<?php
set_error_handler(
function($level, $error, $file, $line){
if(0 === error_reporting()){
return false;
}
throw new ErrorException($error, -1, $level, $file, $line);
},
E_ALL
);
register_shutdown_function(function(){
$error = error_get_last();
if($error){
throw new ErrorException($error['message'], -1, $error['type'], $error['file'], $error['line']);
}
});
set_exception_handler(function($exception){
// ... more code ...
});
require 'NotExists.php';
Note for internals/extensions:
Many opcode values changed between PHP 7.3 and 7.4, so most documentation resources are outdated in that regard. You can look the definitions at Zend/zend_vm_opcodes.h in php-src. For example, ZEND_ECHO changes from 40 to 136.
While opcode changes happen in a lot of PHP versions, the change in 7.4 is quite significant.