Tags
Asked 2 years ago
9 Jun 2021
Views 230
steave

steave posted

error_reporting vs. display_errors in php

error_reporting vs. display_errors in php
angeo

angeo
answered Apr 25 '23 00:00

In PHP, error_reporting and display_errors are two different settings that control how errors are handled.

error_reporting is a PHP configuration directive that determines which errors should be reported by PHP. It is a bitmask that can be set to a combination of different error levels, such as E_ERROR, E_WARNING, E_NOTICE, etc. Setting it to E_ALL will report all errors.

display_errors is another PHP configuration directive that determines whether errors should be displayed to the user. When set to On , errors will be displayed on the screen, while setting it to Off will suppress errors from being displayed.

In production environments, it is recommended to turn off display_errors to prevent sensitive information from being leaked to end-users. Instead, errors should be logged to a file or database using tools like error_log() or a third-party logging library.

In development environments, it is useful to have display_errors turned on so that errors can be identified and fixed quickly. However, it is still important to set the error_reporting level appropriately to avoid overwhelming the developer with too many errors.In PHP, error_reporting and display_errors are two different settings that control how errors are handled.

error_reporting is a PHP configuration directive that determines which errors should be reported by PHP. It is a bitmask that can be set to a combination of different error levels, such as E_ERROR, E_WARNING, E_NOTICE, etc. Setting it to E_ALL will report all errors.

display_errors is another PHP configuration directive that determines whether errors should be displayed to the user. When set to On, errors will be displayed on the screen, while setting it to Off will suppress errors from being displayed.

In production environments, it is recommended to turn off display_errors to prevent sensitive information from being leaked to end-users. Instead, errors should be logged to a file or database using tools like error_log() or a third-party logging library.

In development environments, it is useful to have display_errors turned on so that errors can be identified and fixed quickly. However, it is still important to set the error_reporting level appropriately to avoid overwhelming the developer with too many errors.
Post Answer