[英]How to eliminate php5 Strict standards errors?
After upgrading my PHP to 5.4.3 (WAMP server 2.2), my web app made in CakePHP 1.3, is showing the following errors in my index: 将我的PHP升级到5.4.3(WAMP服务器2.2)之后,我在CakePHP 1.3中制作的Web应用程序在索引中显示以下错误:
Strict standards: Redefining already defined constructor for class Object in C:...\\cake\\cake\\libs\\object.php on line 63
严格的标准:在第63行的C:... \\ cake \\ cake \\ libs \\ object.php中重新定义已经为Object类定义的构造函数
Strict standards: Non-static method Configure::getInstance() should not be called statically in C:...\\cake\\cake\\bootstrap.php on line 49
严格的标准:非静态方法Configure :: getInstance()不应在C:... \\ cake \\ cake \\ bootstrap.php的第49行中静态调用
I've found that some people solve this problem by setting the error_reporting
in php.ini to E_ALL & ~E_STRICT
. 我发现有些人通过将php.ini中的
error_reporting
设置为E_ALL & ~E_STRICT
来解决此问题。
I did that in both php.ini files (C:\\wamp\\bin\\php\\php5.4.3 and C:\\wamp\\bin\\apache\\apache2.4.2\\bin) present on my computer but it didn't solve the problem. 我在计算机上同时存在的两个php.ini文件(C:\\ wamp \\ bin \\ php \\ php5.4.3和C:\\ wamp \\ bin \\ apache \\ apache2.4.2 \\ bin)中都做了此操作,但这并不能解决问题。
I also tried to put php_value error_reporting 6143
in C:...\\cake.htaccess but without success. 我还尝试将
php_value error_reporting 6143
放在C:... \\ cake.htaccess中,但没有成功。
Does anybody know how can I solve this? 有人知道我该怎么解决吗? I can't upgrade my CakePHP because of firebird.
由于有火鸟,我无法升级CakePHP。
One of the changes in php 5.4 is that E_STRICT is now part of E_ALL php 5.4的更改之一是E_STRICT现在是E_ALL的一部分
So, in your /cake/bootstrap.php you could remove the E_STRICT from your error reporting: 因此,在您的/cake/bootstrap.php中,您可以从错误报告中删除E_STRICT:
error_reporting(E_ALL ^ E_STRICT);
and be compatible again with before 5.4 versions. 并再次兼容5.4之前的版本。
Instead of modifying the cake core files, which sucks if you want to update your cake version, go into your Config/core.php file and look for the error handler configuration: 无需修改cake核心文件(如果您要更新cake版本,该文件很烂),请进入Config / core.php文件并查找错误处理程序配置:
Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED,
'trace' => true
));
and replace 'level' with this: 并用以下内容替换“级别”:
...
'level' => E_ALL & ~E_STRICT & ~E_DEPRECATED,
...
Please replace 请更换
error_reporting = E_ALL
in your php.ini , with 在您的php.ini中 ,
error_reporting = E_ALL & ~E_STRICT
For me 为了我
error_reporting(E_ALL ^ E_STRICT);
which is shown in the accepted answer to this question did not work and gave an Infinite loop detected in JError error for my Joomla website. 对此问题的可接受答案中显示的内容无效,并且为我的Joomla网站在JError错误中检测到了一个无限循环 。
You are using newer php version. 您正在使用更新的php版本。 in php 5.4, E_STRICT is part of E_ALL
在php 5.4中,E_STRICT是E_ALL的一部分
in cake 1.3, open file /cake/bootstrap.php and change the error_reporting like this 在cake 1.3中,打开文件/cake/bootstrap.php并更改error_reporting,如下所示
error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
If you're fighting with PHP Strict warnings in cake console output, take a look into your app/config/core.php
. 如果您在蛋糕控制台输出中遇到了PHP Strict警告,请查看一下
app/config/core.php
。
In CakePhp 1.3 error_reporting(...)
is overwritten by the 'log'
option, so ensure you exclude E_STRICT
here: 在CakePhp 1.3中,
error_reporting(...)
被'log'
选项覆盖,因此请确保在此处排除E_STRICT
:
/**
* CakePHP Log Level:
*
* In case of Production Mode CakePHP gives you the possibility to continue logging errors.
*
* The following parameters can be used:
* Boolean: Set true/false to activate/deactivate logging
* Configure::write('log', true);
*
* Integer: Use built-in PHP constants to set the error level (see error_reporting)
* Configure::write('log', E_ERROR | E_WARNING);
* Configure::write('log', E_ALL ^ E_NOTICE);
*/
Configure::write('log', E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
Make sure you've updated the correct php.ini file - if you create a php file in your root directory with the following code 确保已更新正确的php.ini文件-如果使用以下代码在根目录中创建php文件
<?php
phpinfo();
?>
and load it in your web browser it will tell you which ini file is being used, in case you missed one. 并将其加载到您的网络浏览器中,它将告诉您正在使用哪个ini文件,以防您错过其中一个文件。
It's also possible that an htaccess file is setting that value via the php_flag error_reporting
value, which can also be set per directory. htaccess文件也有可能通过
php_flag error_reporting
值来设置该值,该值也可以按目录设置。
File bootstrap.php from folder (root)cake 文件夹(root)cake中的bootstrap.php文件
if (!defined('E_ALL')) {
define('E_ALL', 8192);
}
File debugger.php from folder (root)cake\\libs 从目录(root)cake \\ libs中下载debugger.php文件
error_reporting(E_ALL ^ ~E_STRICT ^ ~E_DEPRECATED);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.