This article explains how to activate the error display for PHP versions from PHP 8.0.

By activating the error display, messages about errors that occur during the execution of the programme code are displayed directly on your website. This makes it possible, for example, to diagnose errors if only a blank or incomplete page is displayed.

Attention

For security reasons, we recommend that you do not permanently activate the error messages in a production environment. Error messages can provide sensitive information that could be useful for potential attackers. In development phases or for acute problem diagnosis, however, it may be useful to temporarily display error messages.

If you want to carry out error diagnostics over a longer period of time, activate error logging instead.

Activate error messages

To activate the display of PHP error messages for your website, add a file with the name .user.ini in the root directory of your website with the following content:

display_errors=On
display_startup_errors=On
error_reporting=E_ALL

If you do not want all error types to be displayed, you can change this by adjusting the line error_reporting=E_ALL. The procedure is described below.

Customize error output

PHP distinguishes between different types of errors. In addition to fatal errors that lead to the script being cancelled, there are also less critical error types such as notifications or warnings. You can specify which error types are displayed using the error_reporting directive.

The following table shows some configuration examples:

CONFIGURATION INSTRUCTION DESCRIPTION
error_reporting = E_ALL All types of error messages are displayed. This configuration instruction was also used above in the instructions section.
error_reporting = E_ERROR Only fatal runtime errors are displayed. These are errors that cannot be rectified. For example, problems with memory allocation. If a fatal error occurs, the execution of the script is cancelled.
error_reporting = E_ERROR | E_WARNING In this example, fatal runtime errors AND warnings are displayed. Warnings in PHP, also known as "warnings", are messages that indicate that a problem has occurred during the execution of a script. In contrast to fatal errors, which cancel the execution of a script, warnings do not cause the script to be cancelled. The script is executed to completion despite the warning. Warnings typically indicate non-critical problems that should be rectified but do not immediately affect the functionality of the programme

If more than one error type is to be configured, these must be listed separated by the character | ( bitwise OR). See above for error_reporting = E_ERROR | E_WARNING.

An overview of the constants predefined for use with 'error_reporting' can be found here: https: //www.php.net/manual/en/errorfunc.constants.php

Further information