0

Just updated my server to PHP 7 and got a lot of errors. One of them in a old plugin is this here:

$str = preg_replace( array(

    // eliminate single line comments in '// ...' form
    '#^\s*//(.+)$#m',
    // eliminate multi-line comments in '/* ... */' form, at start of string
    '#^\s*/\*(.+)\*/#Us',
    // eliminate multi-line comments in '/* ... */' form, at end of string
    '#/\*(.+)\*/\s*$#Us'

   ), '', $str );

| ERROR | preg_replace() - /e modifier is forbidden since PHP 7.0

What is this? I'm a beginner and googled a little bit but found absolutely no good tutorial to fix this.

Thanks for your help :)

ItsOdi
  • 242
  • 1
  • 4
  • 15
  • 1
    because `/e` executes code and is very dangerous. it's basically `eval` in disguise. And it dates back to PHP 5.5 when it was deprecated: http://php.net/manual/en/migration55.deprecated.php – Marc B Oct 12 '16 at 21:30
  • @MarcB Okay understand but how can I fix this? Mhm – ItsOdi Oct 12 '16 at 21:34
  • 2
    Those lines cannot be the issue. Those regexes do not use the /e modifier. – arkascha Oct 12 '16 at 21:38
  • the deprecation notice tells you the solution. you'll have to rewrite the code to match. – Marc B Oct 12 '16 at 21:39
  • @MarcB Okay don't know how to do this I think I have to life with this :) – ItsOdi Oct 12 '16 at 21:46
  • From [the docs](http://php.net/manual/en/function.preg-replace.php), `Support for the /e modifier has been removed. Use preg_replace_callback() instead.` so checkout [preg_replace_callback](http://php.net/manual/en/function.preg-replace-callback.php) – Jeff Puckett Oct 12 '16 at 21:48
  • @JeffPuckettII I've wrote the guy which made this plugin. He should correct this :) – ItsOdi Oct 12 '16 at 22:01

0 Answers0