search
HomeBackend DevelopmentPHP ProblemHow to display error message in php

How to display error message in php

Aug 01, 2020 am 10:36 AM
phpError message

How to set the php display error prompt: first open the "php.ini" file; then turn on the error prompt by setting "display_errors = On"; then add the content "ini_set("error_reporting",E_ALL);" to display All errors are OK.

How to display error message in php

Recommendation: "PHP Video Tutorial"

php error prompt is turned on

Development environment projects usually require error prompts: php.ini file, set display_errors = On

After the project is online, of course you do not want to display the error prompts.

Generally, the php.ini file is not modified directly. The following two lines of code are directly added to the error reporting php file:

ini_set("display_errors", "On");//打开错误提示
ini_set("error_reporting",E_ALL);//显示所有错误

error_reporting error levels include:

E_ALL             - 所有错误和警告(包括PHP 5.4.0中的E_STRICT)
E_ERROR           - 致命的运行时错误
E_RECOVERABLE_ERROR  - 几乎致命的运行时错误
E_WARNING         - 运行时警告(非致命错误)
E_PARSE           - 编译时解析错误
E_NOTICE          - 运行时通知(这些通常是警告,从您的代码中的错误,但它可能是故意的(例如,使用未初始化的变量和赖于它自动初始化为一个事实空字符串)
E_STRICT          - 运行时通知,允许PHP建议更改您的代码将确保最佳的互操作性,并转发代码的兼容性
E_CORE_ERROR      - PHP初始启动期间发生的致命错误
E_CORE_WARNING    - PHP期间发生的警告(非致命错误),初次启动
E_COMPILE_ERROR   - 致命的编译时错误
E_COMPILE_WARNING - 编译时警告(非致命错误)
E_USER_ERROR      - 用户生成的错误消息
E_USER_WARNING    - 用户生成的警告消息
E_USER_NOTICE     - 用户生成的通知消息
E_DEPRECATED      - 警告代码在将来的PHP版本中不起作用
E_USER_DEPRECATED - 用户生成的弃用警告

The most common settings for error_reporting:

E_ALL (显示所有错误,警告和通知,包括编码标准。)
E_ALL & ~E_NOTICE  (显示所有错误,通知除外)
E_ALL & ~E_NOTICE & ~E_STRICT  显示所有错误,通知和编码标准警告除外。)
E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (仅显示错误)

nginx php Turn on PHP error log

php-fpm.conf:
catch_workers_output = yes         ;错误输出选项开启,如果没有添加

php.ini:

error_reporting  =  E_ALL          ;显示所有错误   
display_errors = Off               ;关闭错误提示   
log_errors = On                    ;错误日志开启   
log_errors_max_len = 1024          ;设置日志最大长度   
error_log = /usr/local/error.log   ;错误日志文件位置

The above is the detailed content of How to display error message 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

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

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.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

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.