ecshop cls_template.php 修改

一、关于preg_replace
因为使用PHP5.5.x,ECShop安装完成之后出现了下面提示,特别是在cls_template.php文件中。下面就将需要替换的部分一一替换。

Deprecated: preg_replace(): The /e modifier is deprecated,use preg_replace_callback instead.

下面是需要替换内容:

return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);

替换为:

return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, 
    $source);
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/e" , 
    "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";

替换为:

$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , 
    function($ro) { return stripslashes(trim($ro[1],'\''));}, var_export($t, true)) . ";\n";
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);

替换为:

$val = preg_replace_callback("/\[([^\[\]]*)\]/is", 
    function($ro) {return '.'.str_replace('$','\$',$ro[1]);}, $val);
$source      = preg_replace($pattern, $replacement, $source);

替换为:

$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';
$source = preg_replace_callback($pattern, function($ro)
    {return '{include file='.strtolower($ro[1]). '}';}, $source);

二、关于cls_image::gd_version

将静态调用改为实例调用。
return cls_image::gd_version();

替换为:

$p = new cls_image();

    return $p->gd_version();

三、关于end(explode('.', $tmp));

将连接运算拆分即可。
$ext = end(explode('.', $tmp));

替换为:

$arr = explode('.', $tmp);
$ext = end($arr);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容