How can I replace the deprecated set_magic_quotes_runtime in php?

前端 未结 10 2036
无人及你
无人及你 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:49

    In PHP 7 we can use:

    ini_set('magic_quotes_runtime', 0);
    

    instead of set_magic_quotes_runtime(0);

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

    add these code into the top of your script to solve problem

    @set_magic_quotes_runtime(false);
    ini_set('magic_quotes_runtime', 0);
    
    0 讨论(0)
  • 2020-12-03 04:54

    Update this function :

    if (version_compare(PHP_VERSION, '5.3.0', '<')) {
      set_magic_quotes_runtime(0);
    }
    else {
      ini_set('magic_quotes_runtime', 0);
    }
    $magic_quotes = get_magic_quotes_runtime();
    $file_buffer = fread($fd, filesize($path));
    $file_buffer = $this->EncodeString($file_buffer, $encoding);
    fclose($fd);
    if ($magic_quotes) {
      if (version_compare(PHP_VERSION, '5.3.0', '<')) {
        set_magic_quotes_runtime($magic_quotes);
      }
      else {
        ini_set('magic_quotes_runtime', $magic_quotes);
      }
    }
    
    return $file_buffer;
    
    0 讨论(0)
  • 2020-12-03 04:58

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

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