Merge pull request #211 from gerardroche/gh-pages

Trivial improvements on Error Reporting best practice
This commit is contained in:
Phil Sturgeon
2013-01-14 10:55:15 -08:00

View File

@@ -11,22 +11,21 @@ production (live).
### Development ### Development
To show errors in your <strong>development</strong> environment, configure the following settings in your `php.ini`: To show every possible error during <strong>development</strong>, configure the following settings in your `php.ini`:
- display_errors: On display_errors = On
- error_reporting: -1 display_startup_errors = On
- log_errors: On error_reporting = -1
log_errors = On
From [php.net](http://php.net/manual/function.error-reporting.php): > Passing in the value `-1` will show every possible error, even when new levels and constants are added in future PHP versions. The `E_ALL` constant also behaves this way as of PHP 5.4. - [php.net](http://php.net/manual/function.error-reporting.php)
> Passing in the value -1 will show every possible error, even when new levels and constants are added in future PHP versions. The E_ALL constant also behaves this way as of PHP 5.4.
The `E_STRICT` error level constant was introduced in 5.3.0 and is not The `E_STRICT` error level constant was introduced in 5.3.0 and is not
part of `E_ALL`, however it became part of `E_ALL` in 5.4.0. What does this mean? part of `E_ALL`, however it became part of `E_ALL` in 5.4.0. What does this mean?
In terms of reporting every possible error in version 5.3 it means you must In terms of reporting every possible error in version 5.3 it means you must
use either `-1` or `E_ALL | E_STRICT`. use either `-1` or `E_ALL | E_STRICT`.
**Reporting Every Possibly Error by PHP Version** **Reporting every possible error by PHP version**
* &lt; 5.3 `-1` or `E_ALL` * &lt; 5.3 `-1` or `E_ALL`
* &nbsp; 5.3 `-1` or `E_ALL | E_STRICT` * &nbsp; 5.3 `-1` or `E_ALL | E_STRICT`
@@ -34,15 +33,17 @@ use either `-1` or `E_ALL | E_STRICT`.
### Production ### Production
To hide the errors on your <strong>production</strong> environment, configure your `php.ini` as: To hide errors on your <strong>production</strong> environment, configure your `php.ini` as:
- display_errors: Off display_errors = Off
- error_reporting: E_ALL display_startup_errors = Off
- log_errors: On error_reporting = E_ALL
log_errors = On
With these settings in production, errors will still be logged to the error logs for the web server, but will not be With these settings in production, errors will still be logged to the error logs for the web server, but will not be
shown to the user. For more information on these settings, see the PHP manual: shown to the user. For more information on these settings, see the PHP manual:
* [error_reporting](http://php.net/manual/errorfunc.configuration.php#ini.error-reporting) * [error_reporting](http://php.net/manual/errorfunc.configuration.php#ini.error-reporting)
* [display_errors](http://php.net/manual/errorfunc.configuration.php#ini.display-errors) * [display_errors](http://php.net/manual/errorfunc.configuration.php#ini.display-errors)
* [log_errors](http://php.net/manual/errorfunc.configuration.php#ini.log-errors) * [display_startup_errors](http://php.net/manual/errorfunc.configuration.php#ini.display-startup-errors)
* [log_errors](http://php.net/manual/errorfunc.configuration.php#ini.log-errors)