在php中用reg_replace_回调替换reg_replace
我是OpenCart 2.1的新手,在尝试安装新主题时,我遇到了迁移到PHP5.5的问题。我得到的错误是: 未知:preg_replace():不推荐使用/e修饰符,请使用 preg_replace_回调,而不是在 /Applications/MAMP/htdocs/projects/phpproject1/upload/admin/controller/module/tg_themegloballite_settings.php 在线442。警告:无法修改标题信息-标题已存在 发送人(输出开始于) /Applications/MAMP/htdocs/projects/phpproject1/upload/admin/index.php:80) 在里面 /Applications/MAMP/htdocs/projects/phpproject1/upload/system/library/response.php 在线12 我相信错误在第442行的文件在php中用reg_replace_回调替换reg_replace,php,themes,preg-replace,opencart2.x,preg-replace-callback,Php,Themes,Preg Replace,Opencart2.x,Preg Replace Callback,我是OpenCart 2.1的新手,在尝试安装新主题时,我遇到了迁移到PHP5.5的问题。我得到的错误是: 未知:preg_replace():不推荐使用/e修饰符,请使用 preg_replace_回调,而不是在 /Applications/MAMP/htdocs/projects/phpproject1/upload/admin/controller/module/tg_themegloballite_settings.php 在线442。警告:无法修改标题信息-标题已存在 发送人(输出开始
tg\u themegloballite\u settings.php
中(在下面块的某个地方):
我已经尝试修复它一段时间了,但似乎无法让它工作,因此非常感谢您的帮助。这是一个警告,因为
e
修改器在preg\u replace
函数上的弃用(请参阅)
使用preg\u replace\u callback
的等效替换为:
<?php
function mb_unserialize($serial_str) {
$out = preg_replace_callback(
'!s:(\d+):"(.*?)";!s',
function ($matches) {
return 's:' . strlen($matches[2]) . ':\"' . $matches[2] . '\";';
},
$serial_str);
return unserialize($out);
}
echo "Function test: " . mb_unserialize('s:7:"my test"') . "\n";
<?php
function mb_unserialize($serial_str) {
$out = preg_replace_callback(
'!s:(\d+):"(.*?)";!s',
function ($matches) {
return 's:' . strlen($matches[2]) . ':\"' . $matches[2] . '\";';
},
$serial_str);
return unserialize($out);
}
echo "Function test: " . mb_unserialize('s:7:"my test"') . "\n";