標籤:
ecshop在在PHP5.6.6版本以後,有了很多細微的變化。而ECSHOP官方更新又太慢,發現這些問題後也不及時升級,導致使用者安裝使用過程中錯誤百出。
整理一下我遇到的問題希望對你們能有些幫組也為了自己以後查看。
問題1:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in cls_template.php XXX line
出錯原因:
出現以上問題是 preg_replace() 函數中用到的修飾符 /e 在 PHP5.5.x 中已經被棄用了。在PHP 5.5以上的版本用 preg_replace_callback 函數替換了 preg_replace函數。
解決方案:
解決問題的方法就是將代碼中使用 preg_replace 函數的部分全部替換成 preg_replace_callback 函數,並且將一被廢棄的 /e 修飾符 刪除。
例子:
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->sel ect(‘\\1‘);", $source);
替換為
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->sel ect($r[1]); }, $source);
問題2:
Strict Standards: Only variables should be passed by reference in ......\includes\cls_template.php on line 418
出錯原因:
出現這個問題的原因,貌似在php5.4中array_shift只能為變數,不能是函數傳回值。
解決方案:
$tag_sel = array_shift(explode(‘ ‘, $tag));
替換成
$tag_arr = explode(‘ ‘, $tag);
$tag_sel = array_shift($tag_arr);
問題3:
Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......\includes\lib_base.php on line 346 或者
Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......\includes\lib_installer.php on line 31
出錯原因: //www.zuimoban.com
如問題中提示的一樣,因為 cls_image.php 中 gd_version() 不是 static 函數所以在lib_base.php 與 lib_installer.php 中調用時才會出現以上問題。
解決方案:
解決方案1: 首先在 lib_image.php 檔案中,用 Shift+F 去搜尋 gd_version 函數。然後在gd_version 方法前加 static 修飾符,是此函數變成靜態函數。
解決方案2: 在lib_base.php 與 lib_installer.php 函數中找到 cls_image::gd_version() 部分, 然後分別建立cls_image 執行個體,之後用建立的執行個體再去調用 gd_version() 函數。
$cls_gile = new cls_image();
return $cls_gile->gd_version();
問題4:
Deprecated: Assigning the return value of new by reference is deprecated in…
出錯原因:
PHP5.3+廢除了”=&”符號,對象複製用”=”
解決方案:
搜尋所有PHP檔案,將”=&”替換為”=”
問題5:
Strict Standards: mktime(): You should be using the time() function instead in ......\admin\shop_config.php on line 32
出錯原因:
這個錯誤提示的意思:mktime()方法不帶參數被調用時,會被拋出一個報錯提示。
解決方案:
$auth = mktime();
將mktime()替換成time()方法,代碼為:
$auth = time();
問題6:
Strict Standards: Redefining already defined constructor for class cls_sql_dump ......
出錯原因:
原因跟PHP類中的建構函式有關,PHP早期版本是使用跟類同名的函數作為建構函式,後來又出現了使用 __construct()作為建構函式,
這倆個函數可以同時存在。到了PHP5.4版本,對這倆個函數在代碼中的先後順序有了嚴格的要求。在PHP5.4版本下,必須__construct() 在前,
同名函數在後,否則就會出現上面的的錯誤提示。
解決方案:
把__construct()函數放在,同名函數上面就行了。
問題7:
Strict Standards: Declaration of vbb::set_cookie() should be compatible with integrate::set_cookie($username = ‘‘, $remember = NULL)
出錯問題:
vbb繼承了integrate類並且重寫了 set_cookie() 函數,但vbb重寫set_cookie函數的參數 與 其父類set_cookie 的參數不符所以出現以上問題。
解決方案:
function set_cookie ($username="")
改為
function set_cookie ($username="", $remember = NULL)
如出現類似錯誤,可以以同樣的方法解決。
PHP5.6.6上運行 ecshop 2.7.3常見問題處理