search
HomeBackend DevelopmentPHP ProblemHow to check errors in php

How to check errors in php

Oct 05, 2020 pm 01:13 PM
phpmistake

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

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);

in the inc.php file to

error_reporting(E_ALL);
CODE:[COPY]
error_reporting(E_ALL);

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.