1. 程式人生 > >ECshop在PHP5.3以上版本錯誤處理

ECshop在PHP5.3以上版本錯誤處理

use 替換 version not 開源 lac 剛才 錯誤2 值傳遞

ecshop是一套開源的商城系統,由於出現較早,很多寫法不支持較高版本的PHP,目前PHP5.2對ecshop的支持很少。

一般在高版本的PHP中,會出現一些問題,下面是一些在網上找到的答案,經過自己測試可用。

錯誤1、

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in E:\hx\wamp\www\weixin\includes\cls_template.php on line 300

1)、錯誤原因:
preg_replace() 函數中用到的修飾符 /e 在 PHP5.5.x 中已經被棄用了。

2)、解決辦法:
其實從剛才的錯誤提示信息中我們也能看出一二它提示我們使用 preg_replace_callback 來代替 preg_replace
所以解決方法如下:

使用記事本或其他PHP編輯軟件(如:editplus)打開文件 includes/cls_template.php 找到

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

return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); },

$source);
問題解決。

錯誤2、

Strict standards: Only variables should be passed by reference in E:\hx\wamp\www\weixin\includes\cls_template.php on line 423

錯誤原因:PHP5.3以上默認只能傳遞具體的變量,而不能通過函數返回值傳遞,所以這段代碼中的explode就得移出來重新賦值了

解決辦法:將$tag_sel = array_shift(explode(‘ ‘, $tag));分開寫成

$temp = explode(‘ ‘, $tag);
$tag_sel = array_shift($temp);

錯誤3:Strict standards: Non-static method cls_image::gd_version() should not be called statically in

錯誤原因:不是靜態類中的方法

解決辦法:將return cls_image::gd_version();修改為

$p = new cls_image();
return $p->gd_version();

ECshop在PHP5.3以上版本錯誤處理