How to enable PHP error reporting on web browser

By | August 8, 2020

This tutorial is very much helpful for you if you are debugging an existing project or you are making a new project live, and suddenly your project stopped working, and you want to see errors on your web browser. There are two ways to display errors. The first one is to display error on the web browser directly and the second one is to enable error logging somewhere in text format, known as 'error_log' file. This article will cover the first method that enables error reporting on the web browser. Although, we always recommend not to enable error reporting for the web browser on the live environment because that may cause security issues.

First of all, enable the 'display_errors' variable setting in your server's php.ini file.

display_errors = on

Post, add below lines of code into your PHP file on the top of code or you may also create a config.php file and put below code in it and you can include this in any of your PHP files to enable error reporting. 

ini_set('display_errors', 1);

Below is the example of placing the above code into the file.


Category: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *