Top Hosting Forum

WebHosting Reviews Forum


preg_replace(): The /e modifier is deprecated bbcode.php

PHPBB forum script Discussion. PHPBB Questions, Troubleshooting, Errors, Mods and so on..
Hosting Forum Description
PHPBB forum script Discussion. PHPBB Questions, Troubleshooting, Errors, Mods and so on..

preg_replace(): The /e modifier is deprecated bbcode.php

Postby hostingforum » Thu Aug 01, 2024 12:58 pm

[STDERR] PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in includes/bbcode.php on line 483\n

happens on a viewtopic page..

replace:
$tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);

by:
$tpl = preg_replace_callback(
'/{L_([A-Z_]+)}/',
function ($matches) use ($user) {
$key = $matches[1]; // Get the matched key without {L_ and }
return (!empty($user->lang[$key])) ? $user->lang[$key] : ucwords(strtolower(str_replace('_', ' ', $key)));
},
$tpl
);



Then it started same error on line 112 which seems to be fixed replacing:
$message = preg_replace($preg['search'], $preg['replace'], $message);
$preg = array('search' => array(), 'replace' => array());

by:

$preg = array('search' => array(), 'replace' => array());
$message = preg_replace_callback($preg['search'], function ($matches) use ($preg) {
// Perform the replacement logic here. You can modify this as needed.
$index = array_search($matches[0], $preg['search']);
return $preg['replace'][$index]; // Adjust this logic based on your needs
}, $message);



hostingforum
Site Admin
 
Posts: 671
Joined: Fri May 20, 2011 7:58 pm

Return to PHPBB

Who is online

Users browsing this forum: No registered users and 0 guests

.