Please use the “Print” function at the bottom of the page to create a PDF.
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
Step 1: Create .user.ini file
- Open a simple text editor on your computer. For example Notepad.
- Paste the above lines of code into the text editor.
- Save the document under the name .user.ini. It is important that the file name actually begins with a dot (.).
Step 2: Upload user.ini file to web space
Log in to your IONOS account login.
Click Menu > Hosting in the title bar. If you have multiple hosting contracts, then select the appropriate contract.
The Hosting page is displayed.Click on Use webspace in the Webspace tile.
The Webspace Explorer opens.Click on Upload file.
Select the .user.ini file on your computer.
Click on Upload.
The .user.ini file is uploaded to your web space.
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
- A description of the PHP directives (configuration options) for errors and logging can be found in the official PHP documentation at https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
- Our article Activating error logs shows you how to log error messages in a file