Strict Standards問題,幫忙看下

來源:互聯網
上載者:User
我用的是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直接去掉了,還是沒用,請問這該怎麼解決。分詞功能都能實現,就是出現上面的錯誤報表。


回複討論(解決方案)

只能說你的設定並沒有生效,你是否重啟過apahce, php-fpm呢? 或者你修改的php.ini並非當前解譯器所使用的那個(具體可看phpinfo()中的"configure file"項指定的設定檔位置)

你也可以安裝SCWS 1.2.0版來解決這些問題
2012-3-29: SCWS-1.2.0 Released.
1) 修改 php 擴充代碼以相容支援 php 5.4.x
2) 修正 php 擴充中 scws_get_tops 的 limit 參數不允許少於 10 的問題
3) libscws 增加 scws_fork() 從既有的 scws 執行個體產生分支並共用詞典/規則集,主要用於多線程開發。
4) 新增部分版本的 win32 的 dll 擴充,詳見下載頁面

回一樓: 我用的是wampserver軟體,我就在安裝目錄中改的,改了之後重啟了下,沒用,

出了點小問題,刪乾淨了,在安裝一下,就好了...

是不是有同名的函數 什麼的 自己檢查一下看看。
另外有沒安裝那個zend guard 是的話卸載了看看

我將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 的許可權;其他應用可能需要另外的配置

謝謝各位的協助,我已經按照你們的方法試了,沒有用。我吧我php.ini中的相關代碼給你們看下:
; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED

希望能幫我在想個法子

不是已經跟你說了嗎?
在 php.ini 中令
error_reporting = E_ALL & ~E_STRICT

或在程式中執行
error_reporting( E_ALL & ~E_STRICT );

你的方法我試過了,我把改後的給你看下:;error_reporting = E_ALL & ~E_STRICT
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED

然後我寫了如下測試代碼:
error_reporting(E_ALL ^ E_NOTICE);
$string="調用 segment 方法執行詞彙切割";
require 'pscws3.class.php';

$pscws = new PSCWS3('dict\dict.xdb');
$res = $pscws->segment($string);
print_r($res);

?>
。測試效果還是老樣子

我把所有的建構函式都改了,換了個函數名為非建構函式,錯誤就消失了,但是我不希望用這種方式,我還是希望能用建構函式

error_reporting 函數的設定優先於 php.ini 中的 error_reporting 設定

雖然你在 php.ini 中用 error_reporting = E_ALL & ~E_STRICT 屏蔽了 E_STRICT 層級錯誤
但你在程式中的 error_reporting(E_ALL ^ E_NOTICE); 又將其開啟了

error_reporting( E_ALL & ~E_STRICT & ~E_NOTICE );

多謝多謝,現在終於解決了。謝謝六樓幫忙。嘿嘿。

我也是有這個問題

Strict Standards: Redefining already defined constructor for class PSCWS4 in C:\xampp\htdocs\pscws4\pscws4.class.php on line 120

Strict Standards: Redefining already defined constructor for class XDB_R in C:\xampp\htdocs\pscws4\xdb_r.class.php on line 34

你是按那個辦法解決的?

我也是有這個問題

Strict Standards: Redefining already defined constructor for class PSCWS4 in C:\xampp\htdocs\pscws4\pscws4.class.php on line 120

Strict Standards: Redefining already defined constructor for class XDB_R in C:\xampp\htdocs\pscws4\xdb_r.class.php on line 34

你是按那個辦法解決的?

我也遇到這個問題,然後在php.ini中改錯誤報表層級也沒用,是因為檔案中的error_reporting()順位高於php.ini中,所以需要直接變更檔中的error_reporting層級來屏蔽strict standards提示

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.