Thursday, December 23, 2010

Control PHP Error Reporting With .htaccess

SkyHi @ Thursday, December 23, 2010
Create .htaccess file or use existing .htaccess file in your hosting site. Add below line at the top of file content.

# to stop php startup errors
php_flag display_startup_errors off
# to stop all php errors and warning
php_flag display_errors off

# php directive for setting error level
php_value error_reporting integer

# report everything except run-time notices.
php_value error_reporting 8191
# report both fatal and non-fatal compile-time warnings by the Zend Engine
php_value error_reporting 128
# report run-time notices, compile-time parse errors, run-time errors and warnings
php_value error_reporting 8
# report fatal run-time errors and unrecoverable errors
php_value error_reporting 1

===========================PHP Turn On Error Reporting =========================
To turn on Error Reporting in PHP, this is what I use. You can set this anywhere in your PHP code, but it has to be above the error or else it will not work. This is the easiest way and will work in most hosting environments: