日期:2014-05-17  浏览次数:20392 次

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 的权限;其他应用可能需要另外的配置