开发时建议使用的error_reporting()设置是什么? E_STRICT呢? [英] What is the recommended error_reporting() setting for development? What about E_STRICT?

查看:81
本文介绍了开发时建议使用的error_reporting()设置是什么? E_STRICT呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我使用E_ALL来查看PHP可能对我的代码说的话,以尝试对其进行改进.

Typically I use E_ALL to see anything that PHP might say about my code to try and improve it.

我刚刚注意到一个错误常量E_STRICT,但从未使用过或听说过,这是用于开发的好设置吗?手册说:

I just noticed a error constant E_STRICT, but have never used or heard about it, is this a good setting to use for development? The manual says:

运行时通知.使PHP可以建议对代码进行更改,以确保最佳的互操作性和代码的前向兼容性.

Run-time notices. Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.

所以我想知道我是在E_ALL上使用最佳的error_reporting级别,还是与E_STRICT一起使用才是最好的级别?还是我还需要学习其他组合吗?

So I'm wondering if I'm using the best error_reporting level with E_ALL or would that along with E_STRICT be the best? Or is there any other combination I've yet to learn?

推荐答案

在PHP 5中,E_STRICT所涵盖的内容未包含在E_ALL中,因此,要获取最多的信息,您需要将它们组合起来: /p>

In PHP 5, the things covered by E_STRICT are not covered by E_ALL, so to get the most information, you need to combine them:

 error_reporting(E_ALL | E_STRICT);

在PHP 5.4中,E_STRICT将包含在E_ALL中,因此您只能使用E_ALL.

In PHP 5.4, E_STRICT will be included in E_ALL, so you can use just E_ALL.

您也可以使用

error_reporting(-1);

,它将始终启用所有错误.语义上更正确的是:

which will always enable all errors. Which is more semantically correct as:

error_reporting(~0);

这篇关于开发时建议使用的error_reporting()设置是什么? E_STRICT呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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