Deprecated FeaturesPHP CoreUsing "namespace" as a class constant name
Declaring a class constant
named Returning from a finally block
Using the Nullable return type for __debugInfo()
Declaring a return type of
arraynull for
__debugInfo() is now
deprecated.
Returning Returning values from __construct() and __destruct()
Returning a value from
__construct() or
__destruct() is now
deprecated, and emits a compile-time deprecation notice.
These methods cannot declare a return type, and their return value can
never be observed during normal use, which made returning a value
confusing at best.
Using
For the same reason, using Naming a function readonly
Declaring a function named Using let, is, or _ as an identifier
Using
The
deprecation
of Third argument to define()
Passing the is_a() and is_subclass_of() with a string when allow_string is false
Calling is_a or is_subclass_of
with a string as the first argument while
metaphone()The metaphone function is now deprecated. It implements the original 1990 Metaphone algorithm, which is limited to English pronunciation rules and has long been superseded by Double Metaphone and Metaphone 3. Phonetic algorithms are language-specific and frequently updated, so they are better served by a userland library; use one instead. More than 16 filters in a php://filter URL
Using more than 16 filters in a
php://filter URL without configuring
the Code that needs more filters should either add them with stream_filter_append or stream_filter_prepend, which are not limited, or raise the limit through the context option, for example globally with stream_context_set_default. Passing objects to array_walk(), array_walk_recursive(), and http_build_query()
Passing an object as the
Passing an object as the is_double(), is_long(), is_integer(), and doubleval()Following the deprecation of the non-canonical cast names in PHP 8.5, the function aliases that carry the same outdated type names are now deprecated. They behave identically to their canonical counterparts, which should be used instead:
strcoll() and SORT_LOCALE_STRING
The strcoll function is now deprecated.
It compares strings according to the
The
Bzip2Passing an object as the parameters of the bzip2.compress and bzip2.decompress stream filters is now deprecated, as only an associative array is documented and supported. Call get_object_vars on the object first and pass the resulting array. GMP
The shift ( MBString
The mbregex functions have been deprecated, because the underlying
Oniguruma library is no longer maintained; its maintenance ended in
April 2025.
The functions will be removed in PHP 9.0.
For most use cases the PCRE functions
with the
The
Passing an object as the MySQLiThe mysqli_get_charset function and the mysqli::get_charset method are now deprecated, without replacement. They expose internal implementation details of the character set that have been meaningless since the switch to mysqlnd; in particular the reported collation does not correspond to the collation defined by the server. To get the name of the current character set, use mysqli_character_set_name or mysqli::character_set_name.
The mysqli_stmt_init function and the
mysqli::stmt_init method are now deprecated.
They create an empty statement object that still has to be prepared
before use, and are a source of statement objects left in an
inconsistent state.
Use mysqli_prepare or
mysqli::prepare instead, which prepare the
statement in one step.
For the same reason, calling the
mysqli_stmt::__construct constructor without the
ReflectionCalling ReflectionProperty::setValue or ReflectionProperty::setRawValue with an object that is not an instance of the class on which the property was declared is now deprecated. Unlike the other ReflectionProperty methods, which throw for such objects, these methods silently set a property on the unrelated object, which is no better than a normal assignment and conceptually wrong.
Passing an object to ReflectionMethod::invoke or
ReflectionMethod::invokeArgs when invoking a
static method is now deprecated.
Static methods have no $this, so the object was
ignored entirely and never validated.
Pass SessionPassing an object that does not implement both the SessionIdInterface::create_sid and SessionUpdateTimestampHandlerInterface::validateId methods to session_set_save_handler is now deprecated, regardless of which interfaces the object declares. These methods are required for a save handler to behave correctly under session.use_strict_mode, which is enabled by default as of PHP 8.6 and mitigates session fixation.
Accordingly, an SPLThe spl_classes function is now deprecated. No other extension exposes such a function, and the Reflection extension is always available. Use ReflectionExtension::getClassNames instead. The spl_object_hash function is now deprecated. Since PHP 8.1 its return value has been nothing more than a reformatted spl_object_id, and the name is misleading as the value is not derived from the contents of the object. The string form is also error-prone: two hashes can compare loosely equal because both are numeric strings. Use spl_object_id instead. The following ArrayIterator methods are now deprecated. They only exist because ArrayIterator historically shared its implementation with ArrayObject; most of them make little sense on an iterator and prevent optimizing its implementation. The corresponding ArrayObject methods are not deprecated.
The CSV methods of SplFileObject are now deprecated. Their historical design inconsistencies, further exposed by named arguments, have made them increasingly difficult to maintain, and CSV handling does not naturally belong in SplFileObject. Use fgetcsv and fputcsv on a stream instead.
ZlibPassing an object as the parameters of the zlib.deflate and zlib.inflate stream filters is now deprecated, as only an associative array is documented and supported. Call get_object_vars on the object first and pass the resulting array.
Passing an object as the |