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.
A specialized VM opcode for the array_key_exists()
function has been added, which improves performance of this function
if it can be statically resolved. In namespaced code, this may require
writing \array_key_exists() or explicitly importing
the function.
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 executed if it would otherwise be run as root (which is not allowed for security reasons).
A number of extensions have been migrated to exclusively use pkg-config for the
detection of library dependencies. Generally, this means that instead of using
--with-foo-dir=DIR or similar only
--with-foo is used. Custom library paths can be
specified either by adding additional directories to PKG_CONFIG_PATH
or by explicitly specifying compilation options through FOO_CFLAGS
and FOO_LIBS.
The following extensions and SAPIs are affected:
CURL:
--with-curl no longer accepts a directory.
Enchant:
--with-enchant no longer accepts a directory.
FPM:
--with-fpm-systemd now uses only pkg-config for libsystem checks. The libsystemd minimum required version is 209.
GD:
--with-gd becomes --enable-gd (whether to enable the extension at all) and --with-external-gd (to opt into using an external libgd, rather than the bundled one).
--with-png-dir has been removed. libpng is required.
--with-zlib-dir has been removed. zlib is required.
--with-freetype-dir becomes --with-freetype
--with-jpeg-dir becomes --with-jpeg
--with-webp-dir becomes --with-webp
--with-xpm-dir becomes --with-xpm
IMAP:
--with-kerberos-systemd no longer accepts a directory.
Intl:
--with-icu-dir has been removed. If --enable-intl is passed, then libicu is always required.
LDAP:
--with-ldap-sasl no longer accepts a directory.
Libxml:
--with-libxml-dir has been removed.
--enable-libxml becomes --with-libxml.
--with-libexpat-dir has been renamed to --with-expat and no longer accepts a directory.
LiteSpeed:
--with-litespeed becomes --enable-litespeed.
Mbstring:
--with-onig has been removed. Unless --disable-mbregex has been passed, libonig is required.
ODBC:
--with-iodbc no longer accepts a directory.
--with-unixODBC without a directory now uses pkg-config (preferred). Directory is still accepted for old versions without libodbc.pc.
OpenSSL:
--with-openssl no longer accepts a directory.
PCRE:
--with-pcre-regex has been removed. Instead --with-external-pcre is provided to opt into using an external PCRE library, rather than the bundled one.
PDO_SQLite:
--with-pdo-sqlite no longer accepts a directory.
Readline:
--with-libedit no longer accepts a directory.
Sodium:
--with-sodium no longer accepts a directory.
SQLite3:
--with-sqlite3 no longer accepts a directory.
XSL:
--with-xsl no longer accepts a directory.
Zip:
--with-libzip has been removed.
--enable-zip becomes --with-zip.
fputcsv(),
fgetcsv(),
SplFileObject::fputcsv(),
SplFileObject::fgetcsv(), and
SplFileObject::setCsvControl()
now accept an empty string as $escape argument,
which disables the proprietary PHP escaping mechanism.
The behavior of str_getcsv() has been adjusted accordingly (formerly, an empty string was identical to using the default).
SplFileObject::getCsvControl() now may also return an empty string for the third array element, accordingly.
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
Threshold-cropping now uses the algorithm of system libgd
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.
Support for nsldap and umich_ldap has been removed.
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.
The password_hash() and
password_needs_rehash() functions
now accept nullable string and int for $algo argument.
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.