Table of Contents
PHP的error_reporting错误级别变量对照表,errorreporting
php error reporting 报告有什类型的错误报告
在PHP中,error_reporting(0)表示什?
Home php教程 php手册 PHP的error_reporting错误级别变量对照表,errorreporting

PHP的error_reporting错误级别变量对照表,errorreporting

Jun 13, 2016 am 09:29 AM
error php

PHP的error_reporting错误级别变量对照表,errorreporting

在PHP中所有的报错信息可以用error_reporting()这个函数来设置:

它的参数有字符串和数字两种表示方法,共14个等级,但是呢,我看使用其他数字貌似也可以,起初我以为它指的是一定的报错区间,后来,终于发现了其中的规律:

复制代码 代码如下:

error_reporting( 7 ) = error_reporting( 1+2+4)= error_reporting(E_ERROR | E_WARING | E_PARSE)

现在,我将其总结如下:

数字 常量 说明
1 E_ERROR 致命错误,脚本执行中断,就是脚本中有不可识别的东西出现
举例: Error:Invalid parameters. Invalid parameter name
2 E_WARNING 部分代码出错,但不影响整体运行
举例: Warning: require_once(E:/include/config_base.php)
4 E_PARSE  字符、变量或结束的地方写规范有误
举例:  Parse error: syntax error, unexpected $end in
 E_NOTICE 一般通知,如变量未定义等
举例:  Notice: Undefined variable: p in E:\web\index.php on line 17
16  E_CORE_ERROR PHP进程在启动时,发生了致命性错误
举例:  暂无
32  E_CORE_WARNING 在PHP启动时警告(非致命性错误)
举例:  暂无
64 E_COMPILE_ERROR 编译时致命性错误
举例:  暂无
128 E_COMPILE_WARNING 编译时警告级错误
举例:  暂无
256 E_USER_ERROR  用户自定义的错误消息
举例:  暂无
512 E_USER_WARNING 用户自定义的警告消息
举例:  暂无
1024 E_USER_NOTICE  用户自定义的提醒消息
举例:  暂无
2047 E_ALL 以上所有的报错信息,但不包括E_STRICT的报错信息
举例:  暂无
2048 E_STRICT 编码标准化警告,允许PHP建议如何修改代码以确保最佳的互操作性向前兼容性。

error_reporting 变量的默认值是  E_ALL & ~E_NOTICE
开发时,最佳的值为: E_ALL | E_STRICT

如果设置为:error_reporting(E_ALL | E_STRICT),则表示记录所有的错误信息
可能会导致网站出现一大堆的错误代码;但是对于程序员来说应该说是一件好事,可以把代码优化到最优; 一些非致命性错误虽然不影响程序的运行,但是会加重PHP的负担.


最后,晒出英文版的对照表:

1 E_ERROR Fatal run-time errors. Errors that can not be recovered from. Execution of the script is halted
2 E_WARNING Non-fatal run-time errors. Execution of the script is not halted
4 E_PARSE Compile-time parse errors. Parse errors should only be generated by the parser
8 E_NOTICE Run-time notices. The script found something that might be an error, but could also happen when running a script normally
16 E_CORE_ERROR Fatal errors at PHP startup. This is like an E_ERROR in the PHP core
32 E_CORE_WARNING Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core
64 E_COMPILE_ERROR Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine
128 E_COMPILE_WARNING Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine
256 E_USER_ERROR Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error()
512 E_USER_WARNING Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error()
1024 E_USER_NOTICE User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error()
2048 E_STRICT Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code
4096 E_RECOVERABLE_ERROR Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())
8191 E_ALL All errors and warnings, except level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0)

php error reporting 报告有什类型的错误报告

error_reporting()
在php中有四种类型的错误和警告。它们是:
通常函数错误:1
通常警告:2
分析错误:4
注释(警告用户,可以忽略该信息,但是这个问题可能给您的代码会带来一些错误):8
信息后面的四个数字是该信息类型的表示值,把它们加起来作为错误报告的级别。却省的报告级别是7(即1+2+4),或除了“注释”的其他组合。这个级别能够通过改变php3.ini文件中错误报告指示的方法来改变。它也可以在用户的httpd.conf文件中改变php3错误报告的方法来设置,或者在运行的时候使用脚本语言函数error_reporting()来改变
 

在PHP中,error_reporting(0)表示什?

不让PHP报告有错语发生。如果不关闭好有类似这样的错语

Warning: preg_match()

关闭就不出现了
 

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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles