- 1、如何關閉php的notice和warning問題
- 2、php從5.2升到5.5出現這個怎麼辦PHP Strict Standards: Only variables should be passed by reference in
- 3、如何看待PHP Strict Standards錯誤
- 4、PHP報警Strict Standards如何取消?
- 5、我安裝ECMall後報PHP Strict Standards錯誤,請問如何解決
- 6、php的網頁,提示Strict Standards錯誤,求解決
1、在php.ini文件中改動error_reporting改為:error_reporting=E_ALL ~E_NOTICE
2、如果你不能操作php.ini文件,你可以使用如下方法
在你想禁止notice錯誤提示的頁面中加入如下代碼:
error_reporting(255);
是列出所有提示
error_reporting(0);
是不顯示所有提示
建議使用
error_reporting(7);
只顯示嚴重錯誤
1 E_ERROR 致命的運行時錯誤
2 E_WARNING 運行時警告(非致命性錯誤)
4 E_PARSE 編譯時解析錯誤
8 E_NOTICE 運行時提醒(經常是bug,也可能是有意的)
16 E_CORE_ERROR PHP啟動時初始化過程中的致命錯誤
32 E_CORE_WARNING PHP啟動時初始化過程中的警告(非致命性錯)
64 E_COMPILE_ERROR 編譯時致命性錯
128 E_COMPILE_WARNING 編譯時警告(非致命性錯)
256 E_USER_ERROR 用戶自定義的致命錯誤
512 E_USER_WARNING 用戶自定義的警告(非致命性錯誤)
1024 E_USER_NOTICE 用戶自定義的提醒(經常是bug,也可能是有意的)
2048 E_STRICT 編碼標準化警告(建議如何修改以向前兼容)
4096 E_RECOVERABLE_ERROR 接近致命的運行時錯誤,若未被捕獲則視同E_ERROR
6143 E_ALL 除E_STRICT外的所有錯誤(PHP6中為8191,即包含所
PHP 5.3以後(包括)這個內置函數的值是引用操作的,引用傳遞的參數要求必須是具體的變量,而不能通過函數返回值傳遞。
原代碼:
$testArr = [
0 = ‘a’,
1 = ‘b’,
2 = ‘c’,
3 = ‘d’];
reset(array_flip($testArr));
新代碼:
?php
$testArr = array(
0 = ‘a’,
1 = ‘b’,
2 = ‘c’,
3 = ‘d’);
$newTestArr = array_flip($testArr);
reset($newTestArr);
?
所以你需要檢查$filed的數組定義是否有問題。
錯誤的描述大概如下
Strict Standards: Redefining already defined constructor for class Object in D:\www\hosts\cake\ucake-libs\cake\libs\object.php on line 69
Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\object.php on line 94
Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\security.php on line 48
Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\inflector.php on line 65
Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\configure.php on line 89
Strict Standards: Non-static method Configure::getInstance() should not be called statically in D:\www\hosts\cake\ucake-libs\cake\bootstrap.php on line 43
Strict Standards: Non-static method Configure::write() should not be called statically in D:\www\hosts\cake\ucake-libs\cake\bootstrap.php on line 82
Strict Standards: Non-static method Configure::getInstance() should not be called statically in D:\www\hosts\cake\ucake-libs\cake\libs\configure.php on line 108
大概掃了幾眼,看到基本上是CakePHP框架的錯誤,在Google中搜索相關錯誤信息時發現其它框架也存在這種通病,無耐。。。
只好認真看了看錯誤的解釋,我理解的是:程序沒有按照PHP嚴格規定的模式編寫而給的警告。想到這點於是自己又測試了幾個以前寫的小程序,有的也會出現這個錯誤。看來以後自己得注意自己的編碼規範,不能一味的追求功能…
由於當前項目要進行調試,遂又將php.ini錯誤輸出重新定義為:error_reporting = E_ALL。將E_STRICT去掉了,重啟Apache…一切如常…
這個問題產生是因為引用傳遞參數引起的。
解決辦法:
修改代碼不使用引用傳遞。
修改php配置文件,修改error_reporting 其值改為error_reporting = E_ALL ~E_NOTICE,或者修改函數中的引用方式。
解決辦法:
打開cls_template.php文件中發現下面這段代碼:
1 $tag_sel = array_shift(explode(‘ ‘, $tag));
忘記說了,我的PHP版本是5.4.19,PHP5.3以上默認只能傳遞具體的變量,而不能通過函數返回值傳遞,所以這段代碼中的explode就得移出來重新賦值了
1 $tagArr = explode(‘ ‘, $tag);
2 $tag_sel = array_shift($tagArr);
這樣之後頂部的報錯沒掉了,左側和底部的報錯還需要去ecshop的後台點擊清除緩存才能去除。
下面我們遇到這段代碼,在php5.3以上版本,也會報錯誤。
1 $file_suffix = strtolower(array_pop(explode(‘.’, $file_name)));
修改方法:
1 $fnarray=explode(‘.’, $file_name);
2 $file_suffix = strtolower(array_pop($fnarray));
以後傳參需要單獨寫好,不能一行寫完了。修改配置文件時,最好是複製一行,注掉,然後再改,如果需要隨時切回。
當你的網站出現
Strict Standards: Non-static method ECMall::startup() should not be called statically in /htdocs/ecmall/index.php on line 22
Deprecated: Assigning the return value of new by reference is deprecated in /htdocs/ecmall/eccore/controller/app.base.php on line141
Deprecated: Assigning the return value of new by reference is deprecated in /htdocs/ecmall/includes/ecapp.base.php on line 137
Strict Standards: Declaration of FrontendApp::jslang() should be compatible with ECBaseApp::jslang($lang) in /htdocs/ecmall/app/frontend.base.php on line 363
Strict Standards: Declaration of Message::display() should be compatible with BaseApp::display($n) in /htdocs/ecmall/eccore/controller/message.base.php on line 329
等類似錯誤提示的時候(PHP5.2.*版本的同樣有這情況),可以考慮我們下面給出的解決方法:
1)問題分析:該錯誤是PHP環境配置的問題,並非程序問題;
2)找到php.ini 文件,將 error_reporting 的值改為:error_reporting = E_ALL ~E_NOTICE
3)重啟Apache或者IIS。
4)完畢
提示的意思是:構造方法重複了。
function sms()是兼容php 4.x的語法。php5.x之後引入了__construct
現在php4.x基本已經全被換代升級了,php5.3.3版之後將不認function sms()為構造方法。
這裡代碼中可以刪掉整個function sms(){}
原創文章,作者:WWEHT,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/127095.html