Home > Backend Development > PHP Tutorial > How to effectively shield PHP error prompts_PHP Tutorial

How to effectively shield PHP error prompts_PHP Tutorial

WBOY
Release: 2016-07-15 13:34:44
Original
1490 people have browsed it

How to shield PHP error prompts 1. Add @ before the function that may cause errors, and then or die("")
For example:
@mysql_connect(...) or die("Database Connect Error")

Method 2 for shielding PHP error prompts. Edit php.ini, search for "display_errors =" and change the value after "=" to " off.

Method 3 to block PHP error prompts: Add error_reporting(0) before the php script to block all error prompts.

error_reporting
Configure the level of error message reporting.

Syntax: int error_reporting(int [level]);

Return value: Integer

Function type: PHP system function

Content description of the mask PHP error prompt function

This function is used to configure the level of error message reporting. The parameter level is an integer bitmask, see the table below. >The mask value represents the name

E_ERROR

E_WARNING

E_PARSE

E_NOTICE
E_CORE_ERROR
E_CORE_WARNING

E_NOTICE means that in general, no records will be recorded, only program errors It is only used when trying to access a variable that does not exist, or calling the stat() function to view a file that does not exist.
E_WARNING will usually be displayed, but it will not interrupt the execution of the program. Very effective. For example: calling ereg() with a problematic regular expression will usually display

E_ERROR, which means that memory configuration or other errors cannot be traced with this mask. >E_PARSE Parses errors from the syntax.


E_CORE_ERROR Like E_ERROR, but excludes errors caused by PHP core.
E_CORE_WARNING Like E_WARNING, but excludes PHP core error warnings. 7) = error_reporting( 1+2+4) = error_reporting(E_ERROR | E_WARING | E_PARSE)

The above is the relevant implementation method of shielding PHP error prompts


.

http://www.bkjia.com/PHPjc/445954.html


www.bkjia.com

true

TechArticleHow to shield PHP error prompts 1. Add @ before the function that may cause errors, and then or die() such as: @mysql_connect(...) or die(Database Connect Error) Method 2 to block PHP error prompts, edit...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template