一、关于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);
欢迎转载,注明出处:http://my.oschina.net/xiaohui249/blog/335867
来源:oschina
链接:https://my.oschina.net/u/1010775/blog/335867