Tags
Asked 3 years ago
9 Jun 2021
Views 263
Mahesh Radadiya

Mahesh Radadiya posted

Error Reporting Production vs Development in php

Error Reporting Production vs Development in php
jassy

jassy
answered Apr 25 '23 00:00

In PHP, error reporting can be set to different levels for development and production environments. In development, it's common to set the error reporting level to show all types of errors, warnings, and notices. This can help developers quickly identify and fix issues during the development process.

On the other hand, in production, it's recommended to set the error reporting level to only show critical errors and hide warnings and notices. This is because displaying warnings and notices to end-users can be confusing and potentially harmful.

To set the error reporting level in PHP, you can use the error_reporting function. Here's an example of how to set the error reporting level to show all errors, warnings, and notices:



error_reporting(E_ALL);

And here's an example of how to set the error reporting level to only show critical errors:



error_reporting(E_ERROR);

To set the error reporting level for different environments, you can use a configuration file or environment variable to switch between the different levels. For example, you could set the e rror_reporting level to E_ALL for a development environment and E_ERROR for a production environment.
Post Answer