Avoiding the preg_replace() /e Modifier in PHP
After upgrading PHP, some scripts such as those used in old Drupal systems may report an error on preg_replace() that "the /e modifier is no longer supported" due to the modifier's deprecation and removal for being a security risk. Replace it with preg_replace_callback() to solve the problem.
==========
1. Find the preg_replace() function.
preg_replace ("/".$pattern."/e", $replacement, $subject);
2. Convert it to the preg_replace_callback() function as shown.
preg_replace_callback("/".$pattern."/",
function ($args) { return nameOfCallback($args); },
$subject
);
==========
Comments
Post a Comment