Tags
Asked 2 years ago
9 Jun 2021
Views 176
jagdish

jagdish posted

Error Reporting to Screen, with Line Breaks in php ?

Error Reporting to Screen, with Line Breaks in php ?
debugger

debugger
answered Apr 25 '23 00:00

In PHP, you can set the error reporting level to include all errors, warnings, and notices, and also configure PHP to display them on the screen with line breaks using the following code:



error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('html_errors', 0);

The error_reporting function sets the error reporting level to include all errors, warnings, and notices. The ini_set function sets the display_errors and html_errors directives in the php.ini file to 1 and 0, respectively. This tells PHP to display the errors on the screen and to format them with line breaks.

Note that displaying errors on the screen in a production environment can be a security risk as it may reveal sensitive information to attackers. It is recommended to log the errors to a file instead of displaying them on the screen in a production environment.
Post Answer