How can I replace the deprecated set_magic_quotes_runtime in php?

前端 未结 10 2035
无人及你
无人及你 2020-12-03 03:58

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 /o         


        
相关标签:
10条回答
  • 2020-12-03 04:42

    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);
    }
    
    0 讨论(0)
  • 2020-12-03 04:42

    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

    0 讨论(0)
  • 2020-12-03 04:43
    ini_set('magic_quotes_runtime', 0)
    

    I guess.

    0 讨论(0)
  • 2020-12-03 04:45

    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/

    0 讨论(0)
  • 2020-12-03 04:45

    Gust add the prefix "@" before the function to be @set_magic_quotes_runtime(0); Not supported anymore in php 5.4, and don't remove or disable the function

    0 讨论(0)
  • 2020-12-03 04:48

    Upgrade to version 1.6 of FPDF.

    0 讨论(0)
提交回复
热议问题