Deprecated Features
PHP Core
Implicitly nullable parameter
A parameter's type is implicitly widened to accept null
if the default value for it is null
.
The following code:
should be converted to:
or
However, if such a parameter declaration is followed by a mandatory
parameter:
It must be converted to:
or
as optional parameter before required ones are deprecated.
Raising zero to the power of negative number
Raising a number to the power of a negative number is equivalent to taking
the reciprocal of the number raised to the positive opposite of the power.
Therefore raising 0
to the power of a negative number
corresponds to dividing by 0
.
Thus, this behaviour has been deprecated.
This affects the exponentiation operator **
and the pow function.
If the IEEE 754 semantics are desired one should use the new
fpow function.
Using underscore _
as class name
Naming a class _
is now deprecated:
Note:
Classes whose names start with an underscore are not
deprecated:
Using trigger_error with
E_USER_ERROR
Calling trigger_error with
error_level
being equal to
E_USER_ERROR
is now deprecated.
Such usages should be replaced by either throwing an exception,
or calling exit, whichever is more appropriate.
The E_STRICT
constant
Because the E_STRICT
error level was removed,
this constant is now deprecated.
cURL
The CURLOPT_BINARYTRANSFER
constant is now deprecated.
Date
The DatePeriod::__construct(string $isostr, int $options = 0)
signature has been deprecated.
Use DatePeriod::createFromISO8601String instead.
The SUNFUNCS_RET_TIMESTAMP
,
SUNFUNCS_RET_STRING
,
and SUNFUNCS_RET_DOUBLE
constants are now deprecated.
This follows from the deprecation of the date_sunset and
date_sunrise functions in PHP 8.1.0.
DBA
Passing null
or false
to dba_key_split is now
deprecated.
It would always return false
in those cases.
DOM
The DOM_PHP_ERR
constant is now deprecated.
The following properties have been formally deprecated:
- DOMDocument::$actualEncoding
- DOMDocument::$config
- DOMEntity::$actualEncoding
- DOMEntity::$encoding
- DOMEntity::$version
Hash
Passing invalid options to hash functions is now deprecated.
Intl
Calling intlcal_set or
IntlCalendar::set
with more than two arguments is deprecated.
Use either IntlCalendar::setDate or
IntlCalendar::setDateTime instead.
Calling intlgregcal_create_instance or
IntlGregorianCalendar::__construct
with more than two arguments is deprecated.
Use either IntlGregorianCalendar::createFromDate or
IntlGregorianCalendar::createFromDateTime instead.
LDAP
Calling ldap_connect
with more than two arguments is deprecated.
Use ldap_connect_wallet instead.
Calling ldap_exop
with more than four arguments is deprecated.
Use ldap_exop_sync instead.
MySQLi
The mysqli_ping function and
mysqli::ping method
are now deprecated as the reconnect feature was removed in PHP 8.2.0.
The mysqli_kill function and
mysqli::kill method
are now deprecated.
If this functionality is needed a SQL KILL
command
can be used instead.
The mysqli_refresh function and
mysqli::refresh method
are now deprecated.
If this functionality is needed a SQL FLUSH
command
can be used instead.
All MYSQLI_REFRESH_*
constants have been deprecated as well.
Passing the mode
parameter to
mysqli_store_result explicitly has been deprecated.
As the MYSQLI_STORE_RESULT_COPY_DATA
constant was
only used in conjunction with this function it has also been deprecated.
PDO_PGSQL
Using escaped question marks (??
) inside
dollar-quoted strings is deprecated.
Because PDO_PGSQL now has its own SQL parser with dollar-quoted strings
support, it is no longer necessary to escape question marks inside them.
PGSQL
The 2 arguments signature of pg_fetch_result,
pg_field_prtlen, and
pg_field_is_null is now deprecated.
Use the 3 arguments signature with row
set to
null
instead.
Random
lcg_value is now deprecated,
as the function is broken in multiple ways.
Use Random\Randomizer::getFloat instead.
Reflection
Calling ReflectionMethod::__construct
with one arguments is deprecated.
Use ReflectionMethod::createFromMethodName instead.
SOAP
Passing an int to
SoapServer::addFunction is now deprecated.
If all PHP functions need to be provided flatten the array returned by
get_defined_functions.
The SOAP_FUNCTIONS_ALL
constant is now deprecated.
SPL
The SplFixedArray::__wakeup method is now
deprecated, as it implements
SplFixedArray::__serialize and
SplFixedArray::__unserialize
which need to be overwritten instead.
Using the default value for the escape
parameter for the
SplFileObject::setCsvControl,
SplFileObject::fputcsv, and
SplFileObject::fgetcsv is now deprecated.
It must be passed explicitly either positionally or via named arguments.
This does not apply to SplFileObject::fputcsv
and SplFileObject::fgetcsv if
SplFileObject::setCsvControl was used to set a
new default value.
Standard
Calling stream_context_set_option
with two arguments is deprecated.
Use stream_context_set_options instead.
Unserializing strings using the uppercase S
tag
with unserialize is deprecated.
Using the default value for the escape
parameter for the
fputcsv,
fgetcsv, and
str_getcsv is now deprecated.
It must be passed explicitly either positionally or via named arguments.
XML
The xml_set_object function has been deprecated.
Passing non-callable strings to the
xml_set_*
functions is now deprecated.