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

來源:互聯網
上載者:User

標籤:ref   靜態類   題解   eth   reference   php   odi   php5.5   and   

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以上版本錯誤處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.