標籤:
裝ECShop2.7.3出現了一堆問題,主要是因為PHP版本過高引起的,不願意降低版本,則只能一個個解決啦!這些問題包括:preg_replace、cls_image::gd_version、end(explode(‘.‘, $tmp))。
一、關於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);
安裝ecshop2.7時候的錯誤處理 php版本不相容引起