最新版本的php 适配ecshop
2015-12-07 17:40
706 查看
是不是对最新版本的php 适配ecshop很苦恼.最近我就遇到了这个事情,最终我花了一个小时的时间把这个问题解决了.
特放出来,方便大家查阅.
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 300 的错误,请问我应该怎么改?
这个错误存在于ecshop 最高版本2.7.3 ,在php 5.4 以上版本都存在.
下面我列出需要改动的地方.
用editplus或者其他工具,不建议用记事本,因为可能会改变原有文件的编码格式.
第300行
原有内容:
//return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
修改后内容:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
第491行
原有内容:
//$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改后内容:
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" ,
function($match){return stripslashes(trim($match[1],'\''));}
, var_export($t, true)) . ";\n";
第550行
原有内容:
//$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改后内容:
$val = preg_replace_callback(
'/\[([^\[\]]*)\]/is',
function ($matches) {
return '.'.str_replace('$','\$',$matches[1]);
},
$val
);
第1080行
原有内容:
//$source = preg_replace($pattern, $replacement, $source);
修改后内容:
$source = preg_replace_callback($pattern,
function ($matches) { return '{include file='.strtolower($matches[1]). '}';},
$source);
<
bca8
/p>
替换为后,上传到服务器.然后进入后台,清空缓存即可
特放出来,方便大家查阅.
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 300 的错误,请问我应该怎么改?
这个错误存在于ecshop 最高版本2.7.3 ,在php 5.4 以上版本都存在.
下面我列出需要改动的地方.
用editplus或者其他工具,不建议用记事本,因为可能会改变原有文件的编码格式.
第300行
原有内容:
//return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
修改后内容:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
第491行
原有内容:
//$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改后内容:
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" ,
function($match){return stripslashes(trim($match[1],'\''));}
, var_export($t, true)) . ";\n";
第550行
原有内容:
//$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改后内容:
$val = preg_replace_callback(
'/\[([^\[\]]*)\]/is',
function ($matches) {
return '.'.str_replace('$','\$',$matches[1]);
},
$val
);
第1080行
原有内容:
//$source = preg_replace($pattern, $replacement, $source);
修改后内容:
$source = preg_replace_callback($pattern,
function ($matches) { return '{include file='.strtolower($matches[1]). '}';},
$source);
<
bca8
/p>
替换为后,上传到服务器.然后进入后台,清空缓存即可
相关文章推荐
- phpstorm配置代码自动同步到服务器
- 腾讯云搭建php环境
- php连接postgresql
- PHP开发移动客户端接口---封装接口
- PHP7变量在内核中存储方式
- PHPnow开启PHP扩展里openssl支持的方法
- Netfilter中对FTP连线跟踪的处理
- php安装扩展
- 学习php设计模式 php实现享元模式(flyweight)
- Motorola S-records .ptp文件详解
- PHP位运算符
- PHP全栈工程师学习大纲
- PHP7 安装配置
- 使用 PHP cURL 提交 JSON 数据
- ThinkPHP中Widget的两种写法及调用
- theano —— shared, function(outputs, updates, givens)
- PHP Yii 命令行程序以及定时任务详解
- PHP设计模式
- PHP中json中文乱码问题解决
- PHP保存数组到文件中的方法