Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中用reg_replace_回调替换reg_replace_Php_Themes_Preg Replace_Opencart2.x_Preg Replace Callback - Fatal编程技术网

在php中用reg_replace_回调替换reg_replace

在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。警告:无法修改标题信息-标题已存在 发送人(输出开始

我是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行的文件
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";