PHP error level setting and principle analysis
This article mainly introduces the PHP error level setting and principle analysis. It has certain reference value. Now I share it with everyone. Friends in need can refer to it
Introduction to the principle
In the PHP configuration file, php.ini has the following configuration:
; Error Level Constants: ; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0) ; E_ERROR - fatal run-time errors; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and ; relying on the fact it is automatically initialized to an ; empty string); E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability ; and forward compatibility of your code ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's ; initial startup; E_COMPILE_ERROR - fatal compile-time errors ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) ; E_USER_ERROR - user-generated error message ; E_USER_WARNING - user-generated warning message ; E_USER_NOTICE - user-generated notice message ; E_DEPRECATED - warn about code that will not work in future versions ; of PHP ; E_USER_DEPRECATED - user-generated deprecation warnings; ; Common Values: ; E_ALL (Show all errors, warnings and notices including coding standards.) ; E_ALL & ~E_NOTICE (Show all errors, except for notices) ; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.) ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT; http://php.net/error-reportingerror_reporting = E_ALL
In the above configuration: error_reporting
is to set the configuration level; the default is E_ALL
, which means to display all Notices. Warning, Error information (Show all errors, warnings and notices including coding standards.).
There is a detailed explanation in the PHP manual predefined constants. The following is part of the excerpt:
Example: E_ALL & ~E_NOTICE
E_ALL: 111011111111111
E_NOTICE: 1000
~E_NOTICE: 0111
E_ALL & ~E_NOTICE: 111011111110111
This is how php controls the error level through binary conversion.
Adjust the error level
Global settings
Change the error_reporting in the php.ini
file to achieve the effect.
For example:
1. error_reporting = E_ALL #输出所有错误,警告,notice信息 2. error_reporting = E_ALL & ~E_NOTICE #输出所有错误和警告信息,不输出notice信息 3. E_ALL & ~E_NOTICE & ~E_WARNING #输出所有错误信息,不输出警告,notice信息
Local settings
In a script or program, the effect can be achieved through ini_set() and error_reporting() settings.
For example:
ini_set("display_errors",1) error_reporting(E_ALL)
Related recommendations:
##PHP reports an error and automatically jumps<a href="http://www.php.cn/php-weizijiaocheng-392917.html" target="_self"></a>
PHP error handling in development mode and product mode
The above is the detailed content of PHP error level setting and principle analysis. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.
