Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace get_magic_quotes_runtime() in PHP7.4

Tags:

php

deprecated

The function get_magic_quotes_runtime is deprecated in PHP 7.4 as per documantation.

This function has been DEPRECATED as of PHP 7.4.0. Relying on this function is highly discouraged.

How to replace it with a valid code with the same functionality?

A particular example PunBB v1.4.5, file: common.php line 18:

// Turn off magic_quotes_runtime
if (get_magic_quotes_runtime()) {
    @ini_set('magic_quotes_runtime', false);
}
like image 288
Miroslav Popov Avatar asked Jun 13 '26 04:06

Miroslav Popov


2 Answers

Well it is a reference to magic_quotes_runtime which is itself deprecated as of PHP 5.3 and REMOVED in PHP 5.4 so you have no need to use get_magic_quotes_runtime in PHP 7.4

So you can simply update your code accordingly:

/***
 * Turn off magic_quotes_runtime
 * this function serves no purpose
if (get_magic_quotes_runtime()) {
    @ini_set('magic_quotes_runtime', false);
}
***/

Edit: This is just an example, you can simply delete your shown code ;-)

like image 58
Martin Avatar answered Jun 18 '26 01:06

Martin


The proper way to replace it is to not use. You can do that by

if(version_compare(PHP_VERSION, '7.4.0', '<') && get_magic_quotes_runtime()) {
    @set_magic_quotes_runtime(0);
}
like image 33
stillatmylinux Avatar answered Jun 17 '26 23:06

stillatmylinux