How can I replace the deprecated set_magic_quotes_runtime in php?

set_magic_quotes_runtime alternative
fpdf
php enable magic quotes

I'm getting this message when I try to run a php script I have to use but did not write.

Deprecated: Function set_magic_quotes_runtime() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/fpdf.php on line 1810

Here is line 1810:

set_magic_quotes_runtime(0);

If this is a deprecated function, what can I replace it with?

Thank you very much!

Check if it's on first. That should get rid of the warning and it'll ensure that if your code is run on older versions of PHP that magic quotes are indeed off.

Don't just remove that line of code as suggested by others unless you can be 100% sure that the code will never be run on anything before PHP 5.3.

<?php
// Check if magic_quotes_runtime is active
if(get_magic_quotes_runtime())
{
    // Deactivate
    set_magic_quotes_runtime(false);
}
?>

get_magic_quotes_runtime is NOT deprecated in PHP 5.3. Source: http://us2.php.net/get_magic_quotes_runtime/

How can I replace the deprecated set_magic_quotes_runtime in php , Check if it's on first. That should get rid of the warning and it'll ensure that if your code is run on older versions of PHP that magic quotes are indeed off. Don't just  You don’t need to replace it with anything. The setting magic_quotes_runtime is removed in PHP6 so the function call is unneeded. If you want to maintain backwards compatibility it may be wise to wrap it in a if statement checking phpversion using version_compare

I used FPDF v. 1.53 and didn't want to upgrade because of possible side effects. I used the following code according to Yacoby:

Line 1164:

if (version_compare(PHP_VERSION, '5.3.0', '<')) {
    $mqr=get_magic_quotes_runtime();
    set_magic_quotes_runtime(0);
}

Line 1203:

if (version_compare(PHP_VERSION, '5.3.0', '<')) {
    set_magic_quotes_runtime($mqr);
}

set_magic_quotes_runtime - Manual, Change language: English, Brazilian 4, PHP 5). set_magic_quotes_runtime — Sets the current active configuration setting of magic_quotes_runtime. Warning. This function was DEPRECATED in PHP 5.3.0, and REMOVED as of PHP 7.0.0. get_magic_quotes runtime and set_magic_quotes_runtime are useful when you want to read some data in a binary file using fread() and some bytes in such file may be interpreted as \ (backslash), " (double quotes), ' (simple quote) or any "special" character that has a meaning for string processing.

Since Magic Quotes is now off by default (and scheduled for removal), you can just remove that function call from your code.

get_magic_quotes_runtime - Manual, Change language: This function has been DEPRECATED as of PHP 7.4.0. set_magic_quotes_runtime() - Sets the current active configuration setting of  Fixing set_magic_quotes_runtime deprecated in PHP in PHP Scripts by Prabhu Balakrishnan on March 19, 2012 To fix the deprecated warning causing by PHP 5.3, all you have to do is replace the

In PHP 7 we can use:

ini_set('magic_quotes_runtime', 0);

instead of set_magic_quotes_runtime(0);

Function set_magic_quotes_runtime() is deprecated since PHP 5.3 , Function set_magic_quotes_runtime() is deprecated since PHP 5.3 and removed since PHP 7.0. Closed (fixed). Project: SMTP Authentication  Deprecated: Function set_magic_quotes_runtime is deprecated in Warex's fix worked, but for me, the path was install/index.php. I did the find and replace, and the

You don't need to replace it with anything. The setting magic_quotes_runtime is removed in PHP6 so the function call is unneeded. If you want to maintain backwards compatibility it may be wise to wrap it in a if statement checking phpversion using version_compare

How can I replace the deprecated set magic quotes runtime in php , I m getting this message when I try to run a php script I have to use but did not write. Deprecated: Function set_magic_quotes_runtime() is deprecated in  To resolve the errors output above I modified the application_top.php file by commenting out the below PHP code from line 22. You can comment out a line of PHP code by simply adding “#” in front of the line as shown in the below example output. Original set_magic_quotes_runtime() PHP Function:

Function set_magic_quotes_runtime() is deprecated in PHP 5.3.0, Function set_magic_quotes_runtime() is deprecated in PHP 5.3.0 Either option will accomplish what you desire when using PHP 5.3 It's better to change the error_reporting line because there are a few other deprecated  php at nospam-qualystem dot com ¶ 17 years ago get_magic_quotes runtime and set_magic_quotes_runtime are useful when you want to read some data in a binary file using fread() and some bytes in such file may be interpreted as \ (backslash), " (double quotes), ' (simple quote) or any "special" character that has a meaning for string processing.

Why Magic Quotes are gone in PHP 7, We explain why magic quotes have been removed from PHP, and how to Understanding the status quo helps to strike a balance between continuity and change. the functionality has already been deprecated in PHP 5.3 and PHP 5.4​. Error: Call to undefined function set_magic_quotes_runtime() in . Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Thus, preg_replace is in every way better choice. Note there are some differences in pattern syntax though.

Fixed:”Function set_magic_quotes_runtime() is deprecated in PHP , The problem is “Function set_magic_quotes_runtime() is deprecated in PHP 5.3.​0”. so find set_magic_quotes_runtime(0); and then I replace with  | | since PHP 5.3 and removed since PHP 7.0 1477 | ERROR | INI directive 'magic_quotes_runtime' is deprecated | | since PHP 5.3 and removed since PHP 5.4 1484 | ERROR | Function set_magic_quotes_runtime() is deprecated | | since PHP 5.3 and removed since PHP 7.0 1487 | ERROR | INI directive 'magic_quotes_runtime' is deprecated | | since PHP 5.3

Comments
  • @stereofrog - are you sure? I haven't tested but the get function doesn't show that in the documentation, while the set function clearly does.
  • The get function always returns false in PHP > 5.4, but it is not yet deprecated.
  • This is indeed the best solution. +1
  • see my answer on why this may not be a good idea ( stackoverflow.com/questions/2217955/… )
  • And to back this with code: if(version_compare(PHP_VERSION, '5.3.0', '<')) set_magic_quotes_runtime(0);
  • the magic_quotes_runtime option for ini_set is also Removed in PHP 6.0.0
  • What are potential problems this can cause? The @ sign suppresses errors.