Config PHP errors with Apache htaccess and config

setting php runtime values in apache config or .htaccess:

php_flag display_errors on
php_flag html_errors on
php_value error_reporting int

Where the int value can change depending on PHP version. A value of “1″ will show minimal errors and “8″ should show basic errors, but you can use the constants to find out the value for a particular version of PHP with a runtime statement like
echo E_ALL & ~E_DEPRECATED; (which in 5.3.4 = 22527)

html_errors need to be on if you want fancy stack traces in xdebug or other similar error output.

To turn off all error reporting in a production environment:

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0

Leave a Reply