Backward Incompatible ChangesPHP Core$GLOBALS Access Restrictions
Access to the $GLOBALS array is now subject to
a number of restrictions.
Read and write access to individual array elements like
Usage of static Variables in Inherited MethodsWhen a method using static variables is inherited (but not overridden), the inherited method will now share static variables with the parent method.
Optional parameters specified before required parametersAn optional parameter specified before required parameters is now always treated as required, even when called using named arguments. As of PHP 8.0.0, but prior to PHP 8.1.0, the below emits a deprecation notice on the definition, but runs successfully when called. As of PHP 8.1.0, an error of class ArgumentCountError is thrown, as it would be when called with positional arguments.
Output of the above example in PHP 8.0: Deprecated: Required parameter $flavour follows optional parameter $container in example.php on line 3 Making a bowl of raspberry yogurt. Output of the above example in PHP 8.1: Deprecated: Optional parameter $container declared before required parameter $flavour is implicitly treated as a required parameter in example.php on line 3 ArgumentCountError - makeyogurt(): Argument #1 ($container) not passed
Note that a default value of Return Type Compatibility with Internal ClassesMost non-final internal methods now require overriding methods to declare a compatible return type, otherwise a deprecated notice is emitted during inheritance validation. In case the return type cannot be declared for an overriding method due to PHP cross-version compatibility concerns, a ReturnTypeWillChange attribute can be added to silence the deprecation notice. New Keywords
Resource to Object Migration
Several resources have been migrated to objects.
Return value checks using is_resource should be replaced with checks for
MySQLi
mysqli_fetch_fields, and
mysqli_fetch_field_direct will now always return
The
The
mysqli::connect now returns
The default error handling mode has been changed from "silent" to "exceptions"
See the MySQLi reporting mode
page for more details on what this entails,
and how to explicitly set this attribute.
To restore the previous behaviour use:
Classes extending mysqli_stmt::execute are now required to specify the additional optional parameter. MySQLndThe mysqlnd.fetch_data_copy INI directive has been removed. This should not result in user-visible behavior changes. OpenSSLEC private keys will now be exported in PKCS#8 format rather than traditional format, just like all other keys. openssl_pkcs7_encrypt and openssl_cms_encrypt will now to default using AES-128-CBC rather than RC2-40. The RC2-40 cipher is considered insecure and not enabled by default by OpenSSL 3. PHP Data Objects
Calling PDOStatement::bindColumn with
MySQL Driver
Integers and floats in result sets will now be returned using native
PHP types instead of strings when using emulated prepared statements.
This matches the behavior of native prepared statements.
The previous behaviour can be restored by enabling the
SQLite Driver
Integers and floats in results sets will now be returned using native
PHP types.
The previous behaviour can be restored by enabling the
PharTo comply with the ArrayAccess interface, Phar::offsetUnset and PharData::offsetUnset no longer return a bool. Standardversion_compare no longer accepts undocumented operator abbreviations.
htmlspecialchars,
htmlentities,
htmlspecialchars_decode,
html_entity_decode,
and get_html_translation_table
now use
debug_zval_dump now prints the refcount of a reference
wrappers with their refcount, instead of only prepending
debug_zval_dump now prints Standard PHP Library (SPL)SplFixedArray, will now be JSON encoded like an array |