php5.3之前版本升級至5.3以及更高版本後部分文法簡單歸納

來源:互聯網
上載者:User

標籤:ica   com   target   span   ini   table   notice   oca   error:   

1. Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/www/uugui/cake/libs/object.php on line 117

  將$dispatcher =& new Dispatcher();這樣的文法改成$dispatcher = new Dispatcher();

2. Strict Standards: Non-static method DboFactory::getInstance() should not be called statically in /usr/local/www/uugui/app/common/public.inc.php on line 115

  這是php調用靜態方法的文法。

  將$db = DboFactory::getInstance($config);這樣的文法改成 $dboFactory = new DboFactory();$db = $dboFactory->getInstance($config); 或者將方法改成靜態(static修飾)

3. Deprecated: Function ereg() is deprecated in /usr/local/www/uugui/app/common/ipcheck.php on line 309

  ereg是php匹配Regex的方法,將其替換為preg_match,並在原Regex的首尾添加/

  將ereg方法用preg_match替換,$pattern = "^{$v}.*$";if(ereg($pattern,$tablename)) return "internal";改成$pattern = "/^{$v}.*$/";if(preg_match($pattern,$tablename)) return   "internal";

4. Fatal error: Call-time pass-by-reference has been removed in /usr/local/www/uugui/app/models/diagram.php on line 291

  將array_unshift (&$res,array("time"=>date("Y-m-d H:i:s",$curSec),"val"=>0)) ;改成array_unshift ($res,array("time"=>date("Y-m-d H:i:s",$curSec),"val"=>0)) ;

  被調用的方法的參數列表含有&$,將&$替換為$

5. Notice: Undefined variable: string2 in C:\Inetpub\wwwroot\index.php on line 28

  變數未定義或者初始化造成的錯誤

6. Warning: strftime(): It is not safe to rely on the system‘s timezone settings.

  在php頭部添加方法date_default_timezone_set("PRC");

這些文法問題都可以通過設定php的報錯等級將其屏蔽,php設定debug等級的方法可以是php.ini(此方法作用於全域),也可以是在php頭部設定error_reporting()這個方法只對當前指令碼有效,web工程中index頁面中如用了此方法會將php.ini設定覆蓋。php.ini還可以設定屏蔽所有debug,配置選項可參看http://php.net/manual/zh/ini.php

 

php5.3之前版本升級至5.3以及更高版本後部分文法簡單歸納

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.