Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

php - What is the recommended error_reporting() setting for development? What about E_STRICT?

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

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:

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

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

You can also use

error_reporting(-1);

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

error_reporting(~0);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...