How to check errors in php: 1. Set the error level of PHP by configuring the parameters in [php.ini]. You can add a line in the appropriate position in php.ini; 2. Set the error level through the PHP function [error_reporting]. Set the PHP error level.
How to check the error in php:
1. By configuring the parameter settings in php.ini The error level of PHP can be added by adding a line at the appropriate location in php.ini
error_reporting=E_ALL CODE:[COPY] error_reporting=E_ALL
Note: The implementation in php.ini gives some examples, for example, my local php.ini has the following
;Examples:
;-Show all errors,except for notices and coding standards warnings
##;error_reporting=E_ALL&~E_NOTICE;-Show all errors ,except for notices;error_reporting=E_ALL&~E_NOTICE|E_STRICT;-Show only errors;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR;-Show all errors except for notices and coding standards warnings;error_reporting=E_ALL&~E_NOTICECODE:[COPY];Examples:;-Show all errors,except for notices and coding standards warnings;error_reporting=E_ALL&~E_NOTICE;-Show all errors,except for notices;error_reporting= E_ALL&~E_NOTICE|E_STRICT;-Show only errors;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR;-Show all errors except for notices and coding standards warnings ;error_reporting=E_ALL&~E_NOTICEI just need to add error_reporting=E_ALL below these lines of code and then restart the web service.2. Pass The PHP function error_reporting sets the PHP error reporting level
If you do not have the permission to modify the parameter configuration in php.ini, you can set the error reporting level through this function. Error_reporting() function usage methoderror_reporting(report_level)If the parameter level is not specified, the current error level will be returned. Any number of the above options can be connected with "OR" (using OR or |), so that all required levels of errors can be reported. For example, the following code turns off user-defined errors and warnings, performs certain operations, and then returns to the original error level: //Disable error reportingerror_reporting(0) ;//Report runtime errorserror_reporting(E_ERROR|E_WARNING|E_PARSE);//Report all errorserror_reporting(E_ALL); CODE:[COPY]//Disable error reportingerror_reporting(0);//Report runtime errorserror_reporting(E_ERROR | E_WARNING | E_PARSE);//Report all errorserror_reporting(E_ALL);Then we can include/common in the forum. Changeerror_reporting(0); CODE:[COPY] error_reporting(0);
error_reporting(E_ALL); CODE:[COPY] error_reporting(E_ALL);
Want to learn more about programming To learn, please pay attention to thephp training column!
The above is the detailed content of How to check errors in php. For more information, please follow other related articles on the PHP Chinese website!