lib_base.php on line 346,ecshop裝完后 報錯警告問題更改總結

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)

如出現類似錯誤,可以以同樣的方法解決。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值