非静态方法 PEAR::isError() 不应静态调用 [英] Non-static method PEAR::isError() should not be called statically

查看:63
本文介绍了非静态方法 PEAR::isError() 不应静态调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 RHEL 5x 升级到 CentOS 6x 后,我开始在 httpd 日志中看到这些错误:

After upgrading from RHEL 5x to CentOS 6x, I started seeing these errors in my httpd log:

PHP 严格标准:非静态方法 PEAR::isError() 不应该在第 33 行的/web/sites/blah/somescript.php 中静态调用

PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /web/sites/blah/somescript.php on line 33

我看到了 MDB2 的类似错误.稍后会详细介绍.

I saw similar errors for MDB2. More on that in a sec.

somescript.php:

somescript.php:

32  $mdb2_dbx = MDB2::factory($dsn_mdb2, $mdb2_options);
33  if (PEAR::isError($mdb2_dbx))
34  {
35      $err = '<p>Cannot connect to database: ' . $mdb2_dbx->getMessage();
36      errorHandler($err);
37  }   

我做的第一件事是编辑 /etc/php.ini 并添加 &~E_STRICT错误报告.重新启动 httpd 以加载新配置.仍然收到这些错误消息.

The first thing I did was edit /etc/php.ini and add & ~E_STRICT to error reporting. Restarted httpd to load the new config. Still getting these error messages.

其他人提到了与 MDB2 相同的问题,因此我将这些包更新到了​​测试版.这似乎解决了 MDB2 错误,但我仍然在 httpd 日志文件中收到 PEAR 错误消息.

Others mentioned the same problem with MDB2, so I updated these packages to the beta releases. This seemed to address MDB2 errors, but I'm still getting the PEAR error messages in httpd log file.

系统信息:

# pear list
PEAR               1.9.4   stable
MDB2               2.5.0b5 beta
MDB2_Driver_mysql  1.5.0b4 beta
MDB2_Driver_mysqli 1.5.0b4 beta

# php --version
PHP 5.4.20 (cli) (built: Sep 18 2013 19:55:33) 

# cat /etc/centos-release 
CentOS release 6.4 (Final)

# apachectl -v
Server version: Apache/2.2.15 (Unix)

问题

是否有不同的调用 PEAR::isError() 方法不会产生错误?

Is there a different way of invoking PEAR::isError() that will not produce errors?

推荐答案

不,没有.PEAR::isError 继承自 PHP 4 次.

No there isn't. PEAR::isError is legacy from PHP 4 times.

如果在 php.ini 中改变错误级别还不够,你应该检查

If changing the error level in php.ini is not enough you should check

  • 是否正在加载另一个 php.ini 文件(通过 Apache 检查 phpinfo() 输出)
  • 某些脚本设置了错误级别.

如果所有这些都没有帮助,请在运行时使用 error_level() 函数设置适当的级别,或者如果没有其他帮助,请使用 @ 抑制错误操作员.应该避免使用 @ ,因为它相对慢"(错误报告无论如何都很慢......)并且它可能隐藏其他错误.

If all that doesn't help, set an appropriate level using the error_level() function at runtime, or if nothing else helps, suppress the errors using the @ operator. Using @ should be avoided as it is relatively "slow" (error reporting is slow anyways ...) and it might hide other errors.

长期建议是使用更现代的库.

Long-term suggestion would be to use more modern libraries.

这篇关于非静态方法 PEAR::isError() 不应静态调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆