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?
To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>
Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
error_reporting: It displays all level errors except E-NOTICE, E-STRICT, and E_DEPRECATED level errors. display_errors: By default, the value of display_errors is off.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With