當前位置:首頁 » 編程語言 » phpstrictstandards

phpstrictstandards

發布時間: 2022-08-10 12:22:55

A. php報警:Strict Standards: Only variables should be passed by reference in ......on line 641。

如果是這行的話,應該是因為end函數的原因。
end函數: mixed end
( array &$array
)
你可以看到end的參數是一個引用(reference),而你只能把一個變數的引用作為一個參數傳給函數,而你直接把explode('.',$name)作為參數傳給end函數,所以才有這個提示。
你可以這樣修改,先定義一個變數,然後把這個變數傳給end函數,這樣應該可以取消這個提示:
$tmp_name=explode('.',$name);
$name = substr($name, 0, -strlen($ext)) . "_medium." . end($tmp_name);

B. 我安裝ECMall後報PHP Strict Standards錯誤,請問如何解決

當你的網站出現
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)完畢

C. 安裝 ecshop後報錯 Strict standards: Only variables should be passed by reference in

http://localhost/upload/admin/index.php
進入後台清除下緩存就好了

D. 如何看待PHP Strict Standards錯誤

前天無意修改了php.ini關於錯誤輸出的設置,今天測試一個CakePHP開發的項目時竟然發現多了幾條錯誤提示,雖然不是致命的但也不能忽視。

錯誤的描述大概如下

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…一切如常…

E. php不經過實例化也能調用非靜態方法。

這種非靜態的方法,在php中也可以調用,但是php已經不提倡這樣調用了,會提示一個Strict standards(非標准語法的)的錯誤


F. php傳遞默認參數出錯

這樣是不符合php的規范,你定義的函數參數是引用傳遞(變數前加了&符號),但使用時卻是值傳遞($_result=null),這里有個例子:http://www.hankcs.com/program/jie-jue-strict-standards-only-variables-should-be-passed-by-reference.html。
設置函數參數默認值應該在定義函數的地方,而不是調用的地方,而且應該把預設置默認值的參數放在後面,如上面的函數方法應該改為:
static public function unDB(&$_db, &$_result=NULL){
...

}

這樣在調用這個方法的時候是可以這樣的:DB::unDB($_db);即$_result可以省略

G. php報警Strict Standards:Only variables should be passed by reference in/flashplay.php on line 450

這句的意思是把一個圖片的後綴擴展名接到$name變數上
比如,如果設$name的值隨意為"nihao"; $ad_img中的name文件名為"b.jpg"
語句先獲得"jpg",前接上一個點.再接在"nihao後面,最後得到nihao.jpg
這樣寫法很多,可以用strpos寫,不用explode.

熱點內容
ftp網站下載工具 發布:2024-04-18 21:02:45 瀏覽:48
我的世界手游友好的伺服器 發布:2024-04-18 20:57:20 瀏覽:474
php用什麼打開 發布:2024-04-18 20:09:36 瀏覽:732
python訂閱 發布:2024-04-18 20:09:35 瀏覽:533
python開發桌面軟體 發布:2024-04-18 20:09:34 瀏覽:870
我的世界為什麼伺服器比較流暢 發布:2024-04-18 20:05:22 瀏覽:609
上傳到哪了 發布:2024-04-18 19:45:08 瀏覽:317
一觸即發手機軟體復雜腳本 發布:2024-04-18 19:24:29 瀏覽:39
linux查看文件數 發布:2024-04-18 19:19:17 瀏覽:338
linux下qt編譯兩個小時 發布:2024-04-18 18:56:24 瀏覽:546