ecshop在PHP 5.4以上版本各种错误问题处理
ecshop在PHP 5.4以上版本各種錯誤問題處理
www.111cn.net 更新:2014-06-21 編輯:kupeer 來源:轉載 在php5.4版本之后有很多的函數與功能進行丟棄與升級功能了,現在國內很多CMS都還未按php5.4標準來做了,下面我整理了一些在ecshop在PHP 5.4以上版本各種錯誤問題處理.1、PHP 5.4.X環境下安裝ECShop出現“includes/cls_template.php on line 406”的解決方案。
將 $tag_sel = array_shift(explode(‘ ‘, $tag)); 這句話拆開為兩句。
$tag_arr = explode(‘ ‘, $tag);
$tag_sel = array_shift($tag_arr);
array_shift() 的參數是引用傳遞的,5.3以上默認只能傳遞具體的變量,而不能通過函數返回值 end(&array) 也一樣(后面也會有end的函數,也需要拆分為兩行)。
2、PHP 5.4.X環境下安裝ECShop出現“includes/lib_base.php on line 346”的解決方案。
將 cls_image.php 中 function gd_version() 改成 static function gd_version() 即可。
3、后臺點擊 開店向導 警告的解決方案。
admin/include/modules/payment 下的幾個文件構造函數錯誤,刪掉即可。
4、php5.4下安裝的時候處理問題,Strict Standards: Non-static method cls_image::gd_version() should not be called statically in \install\includes\lib_installer.php on line 31
解決:找到install/includes/lib_installer.php中的第31行?? return cls_image::gd_version();然后在找到include/cls_image.php中的678行,發現gd_version()方法未聲明靜態static,所以會出錯。這時候只要:
將function gd_version()改成static function gd_version()即可。
5、安裝好后出現 Strict standards: Only variables should be passed by reference in \includes\lib_main.php on line 1329
$ext = end(explode('.', $tmp));
修改為:
$ext = explode('.',$tmp);
$ext = end($ext);
6、Strict standards: Only variables should be passed by reference in \includes\cls_template.php on line 418
tag_sel = array_shift(explode(' ', $tag));
修改為:
$tag_arr = explode(' ', $tag); $tag_sel = array_shift($tag_arr);
7、ECSHOP后臺“商店設置”報錯 Strict Standards: mktime(): You should be using the time() function instead in /www/web/zhuli/public_html/admin/sms_url.php on line 31。
php版本問題? mktime()修改為? time()
8、 ECSHOP后臺“商店設置”報錯 Strict Standards: mktime(): You should be using the time() function instead in /www/web/zhuli/public_html/admin/shop_config.php on line 32。
php版本問題? mktime()修改為? time()
3 安裝好后出現 Strict standards: Only variables should be passed by reference in \includes\lib_main.php on line 1329
$ext = end(explode('.', $tmp));
修改為:?
$ext = explode('.',$tmp);
?$ext = end($ext);
?Strict standards: Only variables should be passed by reference in \includes\cls_template.php on line 418
?tag_sel = array_shift(explode(' ', $tag));?
修改為:
?$tag_arr = explode(' ', $tag); $tag_sel = array_shift($tag_arr);
?
array_shift() 的參數是引用傳遞的,5.3以上默認只能傳遞具體的變量,而不能通過函數返回值 end(&array) 也一樣(后面也會有end的函數,也需要拆分為兩行)。
?
修改后到后臺更新緩存
?
4 后臺 Strict standards: Redefining already defined constructor for class alipay in \includes\modules\payment\alipay.php on line 85
?后臺更新緩存
?
5 Strict standards: mktime(): You should be using the time() function instead in \admin\sms_url.php on line 31
php版本問題? mktime()修改為? time()
?
6 Strict standards: Redefining already defined constructor for class alipay in \includes\modules\payment\alipay.php on line 85Call Stack
這里是php4與php5的區別
PHP4中構造方法是一個與類同名的方法,而從PHP5開始,用__construct()做為構造方法,但仍然支持PHP4的構造方法。如果同時使用的話,如果 同名方法在前的話,則會報錯
只需要把 function __construct()移到同名函數之前
?7 Deprecated: Assigning the return value of new by reference is deprecated in? \admin\sitemap.php on line 46
?$sm???? =& new google_sitemap();
???? 在5.3版本之后已經不允許在程序中使用”=&”符號。如果你的網站出現了Deprecated: Assigning the return value of new by reference is deprecated in 錯誤,別著急,先定位到出錯的文件,查找下是不是在程序中使用了”=&”,例如阿茲貓剛才定位到網站程序中發現了下圖的程序,發現使用了”=&”符號,去掉‘&’符號之后程序運行正常。
?
8? PHPStrict Standards: Declaration of ucenter::login() should be compatible with integrate::login($username, $password, $remember = NULL) in \includes\modules\integrates\ucenter.php on line 52 PHP Strict Standards: Declaration of ucenter::add_user() should be compatible with integrate::add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date = 0, $md5password = '') in \includes\modules\integrates\ucenter.php on line 52 PHP Strict Standards: Declaration of ucenter::set_cookie() should be compatible with integrate::set_cookie($username = '', $remember = NULL) in \includes\modules\integrates\ucenter.php on line 52?
?
PHP5.4,子類的方法名如果和父類方法名相同,則子類的參數列表也要和父類的參數列相同。
修改接口文件里面的方法
?
9? ecshop2.7.3 gbk版在php5.4下安裝后,分類名稱文字不顯示問題
htmlspecialchars()從 php5.4.0 版本開始第三個參數字符串編碼的默認值改成了 UTF-8,而ecshop2.7.3 gbk版的中文編碼是 GB2312 編碼的,跟現在的默認參數不一致,導致所有htmlspecialchars()處理的字符都無法顯示。
解決辦法:
$str_converted = htmlspecialchars($str, ENT_COMPAT ,'GB2312');
建議php5.4下不要安裝gbk編碼ecshop。
?
ecshop
?
問題一:商城首頁報錯 Strict Standards: Only variables should be passed by reference in D:\wamp\ecshop\includes\cls_template.php on line 422
解決方法:
找到提示錯誤的文件?cls_template.php 及行號
把?$tag_sel = array_shift(explode(' ', $tag));
改成:
$tag_arr = explode(' ', $tag);?
$tag_sel = array_shift($tag_arr);
并且刪除?D:\wamp\www\ecshop\temp\caches下所有的文件
?
問題二:后臺首頁報錯 Strict Standards: Non-static method cls_image::gd_version() should not be called statically in?D:\wamp\www\ecshop\includes\lib_base.php?on line?346
解決辦法
找到D:\wamp\www\ecshop\includes\cls_image.php文件
搜索?function gd_version?改成?static function gd_version
?
問題三:后臺-商店設置?
Strict Standards: mktime(): You should be using the time() function instead in?D:\wamp\www\ecshop\admin\sms_url.php?on line?31
Strict Standards: mktime(): You should be using the time() function instead in?D:\wamp\www\ecshop\admin\shop_config.php?on line?32
解決辦法
根據錯誤提示 把?mktime()?改成?time()
?
?
問題四:后臺-起始頁
Strict Standards: Redefining already defined c**tructor for class alipay in D:\www\es\includes\modules\payment\alipay.php on line 85
解決辦法
1)、錯誤原因:
PHP 類,有兩種構造函數,一種是跟類同名的函數,一種是 __contruct()。從PHP5.4開始,對這兩個函數出現的順序做了最嚴格的定義,必須是 __c**truct() 在前,同名函數在后
2)、
解決方法:
調換一下兩個函數的前后位置即可。
以 includes/modules/payment/alipay.php??為例:
將下面這兩個函數的位置互換一下就OK了,__contruct()在前,alipay()在后
3)、ECSHOP的很多類文件 都存在這個問題,都需要修改掉。
?
?
問題五:后臺-數據備份?
?Strict standards: Redefining already defined constructor for class cls_sql_dump in D:\wamp\www\ecshop\admin\includes\cls_sql_dump.php on line 90
Strict standards: Non-static method cls_sql_dump::get_random_name() should not be called statically in D:\wamp\www\ecshop\admin\database.php on line 64
解決辦法
根據錯誤提示 把?cls_sql_dump的?function __construct()改到??function cls_sql_dump()的前面
把?cls_sql_dump的?function get_random_name()改成 static? function get_random_name()
?
?
問題六:
?
Deprecated:?Assigning?the?return?value?of?new?by?reference?is?deprecated?in??\admin\sitemap.php?on?line?46
?$sm?????=&?new?google_sitemap();
?
解決辦法
在5.3版本之后已經不允許在程序中使用”=&”符號。如果你的網站出現了Deprecated:?Assigning?the?return?value?of?new?by?reference?is?deprecated?in?錯誤,別著急,先定位到出錯的文件,查找下是不是在程序中使用了”=&”,例如剛才定位到網站程序中發現了下圖的程序,發現使用了”=&”符號,去掉‘&’符號之后程序運行正常
?
?
問題七:
Declaration of phpbb::set_cookie() should be compatible with integrate::set_cookie...
解決辦法:把function set_cookie ($username="") 改為function set_cookie ($username="", $remember = NULL)即可
?
問題八:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in..
解決辦法:
我遇見了有兩處,都在cls_template.php文件中:
?1、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、$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
??替換為
?$val= preg_replace_callback("/\[([^\[\]]*)\]/eis",function($r){return str_replace('$','\$',$r[1]);}, $val);
問題解決
轉載于:https://www.cnblogs.com/F4natasy/p/7115631.html
總結
以上是生活随笔為你收集整理的ecshop在PHP 5.4以上版本各种错误问题处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CodeForces 651B
- 下一篇: 地图上显示div点位