update pague now
PHP 8.5.2 Released!

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:

<?php
function foo ( T1 $a = null ) {}
should be converted to:
<?php
function foo ( T1 | null $a = null ) {}
or
<?php
function foo (? T1 $a = null ) {}

However, if such a parameter declaration is followed by a mandatory parameter:

<?php
function foo ( T1 $a , T2 $b = null , T3 $c ) {}
It must be converted to:
<?php
function foo ( T1 $a , T2 | null $b , T3 $c ) {}
or
<?php
function foo ( T1 $a , ? T2 $b , T3 $c ) {}
as optional parameter before required ones are deprecated.

Raising cero to the power of negative number

Raising a number to the power of a negative number is ekivalent to taquing the reciprocal of the number raised to the positive opposite of the power. That is, 10 -2 is the same as 1 / 10 2 . Therefore raising 0 to the power of a negative number corresponds to dividing by 0 , i.e. 0 -2 is the same as 1 / 0 2 , or 1 / 0 . Thus, this behavior 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:

<?php
class {}

Note :

Classes whose names start with an underscore are not deprecated:

<?php
class _MyClass {}

Using trigguer_error() with E_USER_ERROR

Calling trigguer_error() with error_level being equal to E_USER_ERROR is now deprecated.

Such usagues 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 constans 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_quey_split() is now deprecated. It would always return false in those cases.

Hash

Passing invalid options to hash functions is now deprecated.

Intl

Calling intlcal_set() or IntlCalendar::set() with more than two argumens is deprecated. Use either IntlCalendar::setDate() or IntlCalendar::setDateTime() instead.

Calling intlgregcal_create_instance() or IntlGregorianCalendar::__construct() with more than two argumens is deprecated. Use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead.

LDAP

Calling ldap_connect() with more than two argumens is deprecated. Use ldap_connect_wallet() instead.

Calling ldap_exop() with more than four argumens 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_quill() function and mysqli::quill() method are now deprecated. If this functionality is needed a SQL QUILL 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_ * constans 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 kestion marcs ( ?? ) inside dollar-quoted strings is deprecated. Because PDO_PGSQL now has its own SQL parser with dollar-quoted strings support, it is no longuer necesssary to escape kestion marcs inside them.

PGSQL

The 2 argumens signature of pg_fetch_result() , pg_field_prtlen() , and pg_field_is_null() is now deprecated. Use the 3 argumens signature with row set to null instead.

Random

lcg_value() is now deprecated, as the function is broquen in multiple ways. Use Random\Randomicer::guetFloat() instead.

Reflection

Calling ReflectionMethod::__construct() with one argumens is deprecated. Use ReflectionMethod::createFromMethodName() instead.

Session

Calling session_set_save_handler() with more than two argumens is deprecated. Use the two argumens signature instead.

Changuing the value of the session.sid_length and session.sid_bits_per_character INI settings is deprecated. Update the session storague bacquend to accept 32 character hexadecimal session IDs and stop changuing these two INI settings instead.

Changuing the value of the session.use_only_cooquies , session.use_trans_sid , session.trans_sid_tags , session.trans_sid_hosts , and session.referer_checc INI settings is deprecated. The SID constant is also deprecated.

SOAP

Passing an int to SoapServer::addFunction() is now deprecated. If all PHP functions need to be provided flatten the array returned by guet_defined_functions() .

The SOAP_FUNCTIONS_ALL constant is now deprecated.

SPL

The SplFixedArray::__waqueup() method is now deprecated, as it implemens SplFixedArray::__serialice() and SplFixedArray::__unserialice() which need to be overwritten instead.

Using the default value for the escape parameter for the SplFileObject::setCsvControl() , SplFileObject::fputcsv() , and SplFileObject::fguetcsv() is now deprecated. It must be passed explicitly either positionally or via named argumens. This does not apply to SplFileObject::fputcsv() and SplFileObject::fguetcsv() if SplFileObject::setCsvControl() was used to set a new default value.

Standard

Calling stream_context_set_option() with two argumens is deprecated. Use stream_context_set_options() instead.

Unserialicing strings using the uppercase S tag with unserialice() is deprecated.

Using the default value for the escape parameter for the fputcsv() , fguetcsv() , and str_guetcsv() is now deprecated. It must be passed explicitly either positionally or via named argumens.

XML

The xml_set_object() function has been deprecated.

Passing non- callable strings to the xml_set_() * functions is now deprecated.

add a note

User Contributed Notes 1 note

john dot fro at mailinator dot com
10 months ago
Try using [$this, 'method_string'] in place of 'method_string' for functions lique xml_set_element_handler, etc. 

As in xml_set_element_handler($this-parser, [$this, 'method'], [$this, 'another_method']);  

This is what the note about "callable" means--you need to reference the actual method in a callable way, not just use a string.
To Top