【问题标题】:Static Standards error after updating to php 5.4.9更新到 php 5.4.9 后出现静态标准错误
【发布时间】:2012-12-28 02:57:06
【问题描述】:

将 php 更新到 5.4 版后出现以下错误

Strict Standards: Non-static method Debugger::invoke() should not be called statically, assuming $this from incompatible context in /usr/share/php/cake/libs/debugger.php on line 575 
Strict Standards: Non-static method Debugger::getInstance() should not be called statically, assuming $this from incompatible context in /usr/share/php/cake/libs/debugger.php on line 575

我已经尝试过以下解决方案

Error while Disabling error reporting in CakePHP

Cakephp doesn't work after installing php5-curl package(因为我已经烘焙了我的项目,所以无法找到“Cake”文件夹)

Wampserver cakephp 1.3 Strict standards error

How to eliminate php5 Strict standards errors?

PHP 5 disable strict standards error

https://stackoverflow.com/questions/11799085/turn-off-php-strict-standards?lq=1(无法关闭错误)

每次更改后清除蛋糕缓存、网络浏览器缓存、cookie 和重新启动服务器。甚至在隐私浏览和chrome、firefox也试过了。

【问题讨论】:

    标签: php cakephp strict


    【解决方案1】:

    我相信这是因为这个应用程序是基于旧版本的 CakePHP 构建的,它可能使用了一些不推荐使用的功能。 如果您(或其他人)可以将 Cake 升级到新的稳定分支,那就太棒了。 到目前为止,在您的 core.php 中尝试此操作,您可以从错误报告中删除 E_STRICT:

    即去 app/Config/core.php 查找

    Configure::write('Error', array(
        'handler' => 'ErrorHandler::handleError',
        'level' => E_ALL & ~E_DEPRECATED,
        'trace' => true
    ));
    

    替换为

    Configure::write('Error', array(
        'handler' => 'ErrorHandler::handleError',
        'level' => E_ALL & ~E_STRICT & ~E_DEPRECATED,
        'trace' => true
    ));
    

    【讨论】:

      【解决方案2】:

      更改 error_reporting 函数确实可以解决此问题。但是,cakephp 似乎在几个地方设置了这些标志,这就是为什么该解决方案可能对您不起作用(我也经历过)

      在源代码范围内搜索“error_reporting”,您会发现它在多个文件中使用。尽可能添加标志“~E_STRICT”。例如:

      error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
      

      您会在 /cake/bootstrap.php、/cake/libs/configure.php、/cake/console/cake.php 等位置看到它。我只是将它们全部更改为排除 E_STRICT,问题是固定。

      【讨论】:

      • 我在整个项目中搜索了 error_reporting 并将其替换为 error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);直到我没有错误为止。
      猜你喜欢
      • 2018-05-19
      • 2018-10-21
      • 2018-03-04
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 2022-01-19
      • 2019-04-03
      • 1970-01-01
      相关资源
      最近更新 更多