Code: Select all
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /usr/www/identifier/public/script.php on line 977
- Download the script through SFTP and open it in your favorite text editor (or, edit it directly on the webserver using SSH and a text editor there).
- Go to the line number specified by the error.
- Look for use of the preg_replace() function on this line. The first argument to the function will end in an "e"., the second argument will be after a comma and contain arbitrary code, and the third argument should be a variable. For instance:
Code: Select all
$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\\1))", $source);
- Edit the function call in the following ways.
- Change the function name from preg_replace to preg_replace_callback.
- Remove the "e" at the end of the first argument.
- Replace the text of the second argument with an anonymous function in a form like this:
Replace the "something" with the current value of the second argument.
Code: Select all
function($m) { return something; }
- Remove the quotation marks around the second argument.
- Remove escapes (backslashes) for regular names in the second argument, since they are no longer inside a string -- changing \$ to $, for instance. (If the argument is complicated, you may need to perform other changes to convert it to directly executable PHP code.)
- Change all of the references in the second argument -- which look like \\x, where "x" is a number -- to the form $m[x].
- Re-upload, or save, your script.
- Wait a few seconds, then load your page again to confirm that the error went away.
At the end, in the file, you should have something like this:
Code: Select all
$source = preg_replace_callback('/&#(\d+);/m', function($m) { return utf8_encode(chr($m[1])); } , $source);
To make it prettier, you could put it on multiple lines:
Code: Select all
$source = preg_replace_callback(
'/&#(\d+);/m',
function($m) { return utf8_encode(chr($m[1])); } ,
$source
);