Efficient Debugging in PHP: Enable Error Reporting with .htaccess

  • Post last modified:April 24, 2023
  • Reading time:2 mins read
  • Post category:Uncategorized

Temporarily enabling error reporting in PHP is crucial for effective debugging during the development process. In this article, we will demonstrate how to enable error reporting in PHP using the .htaccess file on an Apache web server.

Using .htaccess file (for Apache web server)

If your PHP application runs on an Apache web server, you can enable error reporting using the .htaccess file. Simply add the following lines to the file:

php_flag display_errors On
php_flag display_startup_errors On
php_value error_reporting -1

This method will apply the error reporting settings to all PHP scripts within the same directory as the .htaccess file and its subdirectories. Don’t forget to revert these changes when transitioning to a production environment.


We hope this article has provided you with a clear understanding of how to use the .htaccess file to temporarily enable error reporting in PHP on an Apache web server. Should you need any further information or assistance, please don’t hesitate to contact us. We are always here to help and ensure that your development experience is as smooth as possible.