ecshop在在PHP5.6.6版本以后,有了很多細微的變化。而ECSHOP官方更新又太慢,發(fā)現(xiàn)這些問題后也不及時升級,導(dǎo)致用戶安裝使用過程中錯誤百出。
整理一下我遇到的問題希望對你們能有些幫組也為了自己以后查看。
問題1:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in cls_template.php XXX line
出錯原因:
出現(xiàn)以上問題是 preg_replace() 函數(shù)中用到的修飾符 /e 在 PHP5.5.x 中已經(jīng)被棄用了。在PHP 5.5以上的版本用 preg_replace_callback 函數(shù)替換了 preg_replace函數(shù)。
解決方法:
解決問題的方法就是將代碼中使用 preg_replace 函數(shù)的部分全部替換成 preg_replace_callback 函數(shù),并且將一被廢棄的 /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 ......includescls_template.php on line 418
出錯原因:
出現(xiàn)這個問題的原因,貌似在php5.4中array_shift只能為變量,不能是函數(shù)返回值。
解決方法:
$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 ......includeslib_base.php on line 346 或者
Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......includeslib_installer.php on line 31
出錯原因: //www.zuimoban.com
如問題中提示的一樣,因為 cls_image.php 中 gd_version() 不是 static 函數(shù)所以在lib_base.php 與 lib_installer.php 中調(diào)用時才會出現(xiàn)以上問題。
解決方法:
解決方法1: 首先在 lib_image.php 文件中,用 Shift+F 去搜索 gd_version 函數(shù)。然后在gd_version 方法前加 static 修飾符,是此函數(shù)變成靜態(tài)函數(shù)。
解決方法2: 在lib_base.php 與 lib_installer.php 函數(shù)中找到 cls_image::gd_version() 部分, 然后分別創(chuàng)建cls_image 實例,之后用創(chuàng)建的實例再去調(diào)用 gd_version() 函數(shù)。
$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+廢除了”=&”符號,對象復(fù)制用”=”
解決方法:
搜索所有PHP文件,將”=&”替換為”=”
問題5:
Strict Standards: mktime(): You should be using the time() function instead in ......adminshop_config.php on line 32
出錯原因:
這個錯誤提示的意思:mktime()方法不帶參數(shù)被調(diào)用時,會被拋出一個報錯提示。
解決方法:
$auth = mktime();
將mktime()替換成time()方法,代碼為:
$auth = time();
問題6:
Strict Standards: Redefining already defined constructor for class cls_sql_dump ......
出錯原因:
原因跟PHP類中的構(gòu)造函數(shù)有關(guān),PHP早期版本是使用跟類同名的函數(shù)作為構(gòu)造函數(shù),后來又出現(xiàn)了使用 __construct()作為構(gòu)造函數(shù),
這倆個函數(shù)可以同時存在。到了PHP5.4版本,對這倆個函數(shù)在代碼中的先后順序有了嚴(yán)格的要求。在PHP5.4版本下,必須__construct() 在前,
同名函數(shù)在后,否則就會出現(xiàn)上面的的錯誤提示。
解決方法:
把__construct()函數(shù)放在,同名函數(shù)上面就行了。
問題7:
Strict Standards: Declaration of vbb::set_cookie() should be compatible with integrate::set_cookie($username = '', $remember = NULL)
出錯問題:
vbb繼承了integrate類并且重寫了 set_cookie() 函數(shù),但vbb重寫set_cookie函數(shù)的參數(shù) 與 其父類set_cookie 的參數(shù)不符所以出現(xiàn)以上問題。
解決方法:
function set_cookie ($username="")
改為
function set_cookie ($username="", $remember = NULL)
如出現(xiàn)類似錯誤,可以以同樣的方法解決。
新聞熱點
疑難解答
圖片精選