📅  最后修改于: 2023-12-03 15:33:28.815000             🧑  作者: Mango
The error_reporting()
function in PHP is used to set the level of error reporting for PHP scripts. It determines which errors and warnings are displayed to the user.
error_reporting(level);
Where level
is an optional parameter that specifies the level of error reporting to be set.
The following are the different error reporting values that can be used with the error_reporting()
function:
E_ALL
: This value reports all errors except strict errors.E_ERROR
: This value reports only fatal run-time errors.E_WARNING
: This value reports non-fatal run-time errors.E_NOTICE
: This value reports runtime notices.E_DEPRECATED
: This value reports usage of deprecated code.E_STRICT
: This value reports errors that do not necessarily illuminate coding mistakes.More values and combinable options can be found in the PHP documentation.
To set the level of error reporting in PHP, simply call the error_reporting()
function and pass in the desired value. For example:
error_reporting(E_ALL);
This will set the error reporting level to report all errors except strict errors.
To turn off error reporting altogether, use the following code:
error_reporting(0);
This will prevent any errors from being displayed.
The error_reporting()
function is a very important tool for debugging and troubleshooting PHP scripts. By setting the right level of error reporting, developers can easily identify and fix coding mistakes.