• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Strict Standards问题,帮忙看下

php 搞代码 4年前 (2022-01-23) 23次浏览 已收录 0个评论
文章目录[隐藏]

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

@本文来*源gaodai#ma#com搞*!代#%^码$网* 谢谢各位的帮助,我已经按照你们的方法试了,没有用。我吧我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

然后我写了如下测试代码:
<?php
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提示


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Strict Standards问题,帮忙看下

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址