一:问题原因
preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。
如果你的PHP版本恰好是PHP5.5.X及以上,那你的ECSHOP肯定就会报类似下面这样的错误:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in......
二:大商创198版本在php5.6运行(调试通过)
直接上代码
//文件includes\cls_template.php
//218行修改
return preg_replace("/{([^\\}\\{\n]*)}/e", '$this->select(\'\\1\');', $source);
return preg_replace_callback("/{([^\\}\\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
//372行修改
$out = "<?php \n" . '$k = ' . preg_replace('/(\\\'\\$[^,]+)/e', 'stripslashes(trim(\'\\1\',\'\\\'\'));', var_export($t, true)) . ";\n";
$out = "<?php \n" . '$k = ' . preg_replace_callback('/(\\\'\\$[^,]+)/', function($r) {return stripslashes(trim($r[1], '\'')); }, var_export($t, true)) . ";\n";
//418行修改
$val = preg_replace('/\\[([^\\[\\]]*)\\]/eis', '\'.\'.str_replace(\'$\',\'$\',\'\\1\')', $val);
$val = preg_replace_callback('/\\[([^\\[\\]]*)\\]/', function($r) { return '.' . str_replace('$', '$', $r[1]);}, $val);
//866-868行,前面3行改为下面的2行
$pattern = '/<!--\\s#BeginLibraryItem\\s\\"\\/(.*?)\\"\\s-->.*?<!--\\s#EndLibraryItem\\s-->/se';
$replacement = '\'{include file=\'.strtolower(\'\\1\'). \'}\'';
$source = preg_replace($pattern, $replacement, $source);
$pattern = '/<!--\\s#BeginLibraryItem\\s\\"\\/(.*?)\\"\\s-->.*?<!--\\s#EndLibraryItem\\s-->/s';
$source = preg_replace_callback($pattern, function($r) {return '{include file=' . strtolower($r[1]) . '}'; }, $source);
//文件includes\lib_base.php
//1231行修改
$out = preg_replace('!s:(\\d+):"(.*?)";!se', '\'s:\'.strlen(\'$2\').\':"$2";\'', $serial_str);
$out = preg_replace_callback('!s:(\\d+):"(.*?)";!s', function($r) { return 's:' . strlen($r[2]) . ':"' . $r[2] . '";';}, $serial_str);
三:Ecshop代码修改,未试过
//Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 300
return preg_replace("/{([^\}\{]*)}/e", "\$this->select('\\1');", $source);
return preg_replace_callback("/{([^\}\{]*)}/", function($r) { return $this->select($r[1]); }, $source);
//Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 491
$out = "<?php " . '$k = ' . preg_replace("/(\'\\$[^,] )/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";";
$out = "<?php " . '$k = ' . preg_replace_callback("/(\'\\$[^,] )/" , function($match){return stripslashes(trim($match[1],'\''));}, var_export($t, true)) . ";"
//Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 550
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
$val = preg_replace_callback('/\[([^\[\]]*)\]/is',function ($matches) {return '.'.str_replace('$','\$',$matches[1]);},$val);
//Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 1074
$source = preg_replace($pattern, $replacement, $source);
$source = preg_replace_callback($pattern, function ($matches) { return '{include file='.strtolower($matches[1]). '}';},$source);
//Strict Standards: Only variables should be passed by reference in ...\upload\includes\lib_main.php on line 1329
//原有内容:
$ext = end(explode('.', $tmp));
//修改后内容:
$extsub = explode('.', $tmp);
$tmp = end($extsub);
$tmp = basename($tmp,".$ext");
四:将代码修改后,进入后台,清空缓存,刷新页面即可。
来源:CSDN
作者:喜爱cpp
链接:https://blog.csdn.net/enjoycpp/article/details/103747341