Deprecated features in PHP 7.2.x
Unquoted strings
Unquoted strings that are non-existent global constants are taken to be
strings of themselves. This behaviour used to emit an
E_NOTICE
, but will now emit an
E_WARNING
. In the next major version of PHP, an
Error exception will be thrown instead.
<?php
var_dump(NONEXISTENT);
/* Output:
Warning: Use of undefined constant NONEXISTENT - assumed 'NONEXISTENT' (this will throw an Error in a future version of PHP) in %s on line %d
string(11) "NONEXISTENT"
*/
png2wbmp() and jpeg2wbmp()
The png2wbmp() and jpeg2wbmp() functions from the GD extension have now been deprecated and will be removed in the next major version of PHP.
INTL_IDNA_VARIANT_2003
variant
The Intl extension has deprecated the
INTL_IDNA_VARIANT_2003
variant, which is currently
being used as the default for idn_to_ascii() and
idn_to_utf8(). PHP 7.4 will see these defaults changed to
INTL_IDNA_VARIANT_UTS46
, and the next major version of
PHP will remove INTL_IDNA_VARIANT_2003
altogether.
__autoload() method
The __autoload() method has been deprecated because it is inferior to spl_autoload_register() (due to it not being able to chain autoloaders), and there is no interoperability between the two autoloading styles.
track_errors
ini setting and $php_errormsg variable
When the track_errors
ini setting is enabled, a
$php_errormsg variable is created in the local scope when
a non-fatal error occurs. Given that the preferred way of retrieving such
error information is by using error_get_last(), this
feature has been deprecated.
create_function() function
Given the security issues of this function (being a thin wrapper around eval()), this dated function has now been deprecated. The preferred alternative is to use anonymous functions.
mbstring.func_overload
ini setting
Given the interoperability problems of string-based functions being used in environments with this setting enabled, it has now been deprecated.
(unset) cast
Casting any expression to this type will always result in NULL
, and so
this superfluous casting type has now been deprecated.
parse_str() without a second argument
Without the second argument to parse_str(), the query string parameters would populate the local symbol table. Given the security implications of this, using parse_str() without a second argument has now been deprecated. The function should always be used with two arguments, as the second argument causes the query string to be parsed into an array.
gmp_random() function
This function generates a random number based upon a range that is calculated by an unexposed, platform-specific limb size. Because of this, the function has now been deprecated. The preferred way of generating a random number using the GMP extension is by gmp_random_bits() and gmp_random_range().
each() function
This function is far slower at iteration than a normal foreach, and causes implementation issues for some language changes. It has therefore been deprecated.
assert() with a string argument
Using assert() with a string argument required the string to be eval()'ed. Given the potential for remote code execution, using assert() with a string argument has now been deprecated in favour of using boolean expressions.
$errcontext argument of error handlers
The $errcontext argument contains all local variables of the error site. Given its rare usage, and the problems it causes with internal optimisations, it has now been deprecated. Instead, a debugger should be used to retrieve information on local variables at the error site.
read_exif_data() function
The read_exif_data() alias has been deprecated. The exif_read_data() function should be used instead.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-migration72.deprecated.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.