Strict Standards問題,幫忙看下
我用的是php5.4.剛安裝了scws分詞模組,但是運行時出現如下情況:
Strict Standards: Redefining already defined constructor for class PSCWS3 in D:\php\wamp\www\scws\pscws3.class.php on line 145
Strict Standards: Redefining already defined constructor for class PSCWS23_Dict in D:\php\wamp\www\scws\dict.class.php on line 48
Strict Standards: Redefining already defined constructor for class xdb_Dictionary in D:\php\wamp\www\scws\dict.class.php on line 148
Strict Standards: Redefining already defined constructor for class dba_Dictionary in D:\php\wamp\www\scws\dict.class.php on line 201
Strict Standards: Redefining already defined constructor for class sql_Dictionary in D:\php\wamp\www\scws\dict.class.php on line 257
Strict Standards: Redefining already defined constructor for class txt_Dictionary in D:\php\wamp\www\scws\dict.class.php on line 315
Strict Standards: Redefining already defined constructor for class XDB_R in D:\php\wamp\www\scws\xdb_r.class.php on line 34
php.ini中的錯誤報表error_reporting我也改了,我將error_reporting = E_ALL & ~E_NOTICE直接去掉了,還是沒用,請問這該怎麼解決。分詞功能都能實現,就是出現上面的錯誤報表。
分享到:
------解決方案--------------------
我將error_reporting = E_ALL & ~E_NOTICE直接去掉了,還是沒用
你這是什麼意思?
注釋掉 error_reporting,即不設定 error_reporting 時,php 將按預設的最嚴格的方式檢查錯誤
對於 Strict Standards 類型錯誤,php5.3 預設不檢查,而php5.4預設檢查
開發環境中一般應有
error_reporting = E_ALL
------解決方案--------------------
E_STRICT
這樣可以發現你的程式隱患
關於出錯的原因:
在 pscws3.class.php 中
82行 class PSCWS3
103行 function PSCWS3($dictfile = '')
145行 function __construct($dictfile = '') { $this->PSCWS3($dictfile); }
其中103行的方法名 PSCWS3 與類名相同,被視為建構函式(相容php4)
145行又聲明了建構函式(php5)
所以出錯
在不改動代碼的情況下,可令
error_reporting = E_ALL & ~E_STRICT
來迴避此錯誤
實際應用時應在公用代碼中加入
error_reporting( E_ALL & ~E_STRICT );
而不是修改 php.ini
因為你可能沒有修改 php.ini 的許可權;其他應用可能需要另外的配置