search
HomeBackend DevelopmentPHP ProblemWhat is error handling in PHP? Error code? Wrong trigger?

The previous article introduced you to "What are the two article loading paths in PHP? What is the file path? 》, this article continues to introduce to you what is error handling in PHP? Error code? Wrong trigger? It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

What is error handling in PHP? Error code? Wrong trigger?

Error handling:

refers to when the system (or user) executes certain codes , if an error is found, the programmer will be notified through

error handling.

Error classification:

1) Syntax error: The code written by the user does not comply with PHP's syntax specifications. Syntax errors will cause the code to fail during the compilation process, so The code will not execute (Parseerror).

2) Runtime error: The code is compiled successfully, but during the execution of the code there will be errors (runtime error) caused by unsatisfied conditions.

3) Logic errors: The programmer was not standardized enough when writing the code, and some logical errors occurred, causing the code to execute normally, but not getting the desired results,

$a= 10;
If(Sa= 1){
//最常见把比较符号写成赋值符号
//执行代码。

Error code:

All error codes seen are defined as system constants in PHP (can be used directly).

1) System error:.

E_ PARSE: Compilation error, code will not be executed.

E_ ERROR: fatal error, a fatal error, will cause the code to not continue to execute correctly (break at the error location).

E_ WARNING: warning, warning error, will not affect code execution, but may get unexpected results.

E_ _NOTICE: notice, notification error, will not affect code execution.

2) User error:

E_ _USER ERROR,

E_ USER_ WARNING,

E_ _USER_ _NOTICE.

The error code the user will use when using a custom error trigger (the system will not use it).

3) Others:

E _ALL, which represents all slave errors (usually used more during error control), it is recommended that during the development process ( development environment).

All error constants (code names) starting with E are actually stored in one byte, and then each error occupies a bit corresponding to

. If you want to make some errors The control can be operated using bit operations.

Exclude notification level notice: E_ ALL& ~E_NOTICE.

Only warnings and notifications: E_ WARNING | E_ NOTICE.

Error trigger:


    Triggered when the program is running: The system automatically compares the corresponding error information after an error occurs and outputs it to the user: mainly for syntax errors and runtime errors in the code.
  • Human triggering: Knowing that some logic may go wrong, use the corresponding judgment code to trigger a response error prompt.
  • Recommended learning: "
PHP Video Tutorial

"

The above is the detailed content of What is error handling in PHP? Error code? Wrong trigger?. 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

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment