How to enable PHP error reporting via .htaccess file


Sometimes it's useful to show PHP errors that a script generated for debugging. But on many servers including mine, php.ini's configuration has disabled error displaying for security purposes.

Can I use the .htaccess to display PHP errors for debugging?


You can enable error reporting under Apache, even if you don't have administrator rights and can't access main httpd.conf file.

To enable error reporting in PHP, use your favorite text editor and add the following line to the .htaccess file located in the directory where your .php files reside:

php_flag display_errors on

This will override Apache's default settings to display PHP errors, unless your Apache configuration doesn't allow this modification.