How to check errors in php

coldplay.xixi
Release: 2023-03-06 11:58:01
Original
3765 people have browsed it

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 errors in php

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
Copy after login

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_NOTICE

CODE:[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_NOTICE

I 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 method

error_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 reporting

error_reporting(0) ;

//Report runtime errors

error_reporting(E_ERROR|E_WARNING|E_PARSE);

//Report all errors

error_reporting(E_ALL);

CODE:[COPY]

//Disable error reporting

error_reporting(0);

//Report runtime errors

error_reporting(E_ERROR | E_WARNING | E_PARSE);

//Report all errors

error_reporting(E_ALL);

Then we can include/common in the forum. Change

error_reporting(0);
CODE:[COPY]
error_reporting(0);
Copy after login

in the inc.php file to

error_reporting(E_ALL);
CODE:[COPY]
error_reporting(E_ALL);
Copy after login
and save it, so that you can see the error message reported by PHP

Want to learn more about programming To learn, please pay attention to the

php 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template