Non-static method PEAR::isError() should not be called statically

后端 未结 3 1699
[愿得一人]
[愿得一人] 2021-01-11 16:48

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

PHP Strict Standards: Non-static method PEAR::isError() sh

相关标签:
3条回答
  • 2021-01-11 17:33

    It may be worth noting that that calling PEAR::isError($obj) with one argument is equivalent to is_a($obj, 'PEAR_Error'), if you're updating your own code. I know it is not best practice to "unwrap" a library method like that, but it is basically just an "instance of" check.

    0 讨论(0)
  • 2021-01-11 17:39

    I'm afraid @johannes is incorrect - this is very doable. Simply substitute this in your recipe:

    if ((new PEAR)->isError($mdb2_dbx)) {
        // Victory! Er, I mean, Error!
        ...
    }
    
    0 讨论(0)
  • 2021-01-11 17:45

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

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

    • whether there is another php.ini file being loaded (check phpinfo() output via Apache)
    • some script sets the 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.

    0 讨论(0)
提交回复
热议问题