ecshop以及一些須要注意的

Deprecated: Assigning the return value of new by reference is deprecated inphp

定位到出錯的那一行:html

[php]  view plain copy print ?
 
  1. $this->_ole =& new OLERead();  

我本地環境用的是PHP/5.3.3。sql

下面這段話引用於因思而變cookie

解決辦法:php5.3開始後,廢除了php中的」=&」符號,因此要想複製,直接用=引用便可。詳細以下:dom

一、PHP5對象複製是採用引用的方式;
二、若是不採用引用方式,則須要在複製對象時加關鍵字 clone;
三、若是在複製的過程當中,同時要變動某些屬性,則增長函數_clone();函數

 

 

在PHP5.3以上版本運行ecshop出現的問題及解決方案

 

ecshop網站

 

問題一:商城首頁報錯 Strict Standards: Only variables should be passed by reference in D:\wamp\ecshop\includes\cls_template.php on line 422this

解決方法:google

找到提示錯誤的文件 cls_template.php 及行號url

把 $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()在後

  1.    function alipay()    {
  2.     }
  3.  
  4.     function __contruct()
  5.     {
  6.         $this->alipay();
  7.     }


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文件中:

 一、return preg_replace("/{([^\}\{\n]*)}/e", "\$this->sel ect('\\1');", $source);
替換爲
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->sel ect($r[1]); }, $source);
問題解決。

二、$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);

  替換爲

 $val= preg_replace_callback("/\[([^\[\]]*)\]/eis",function($r){return str_replace('$','\$',$r[1]);}, $val);

問題解決

相關文章
相關標籤/搜索