Home > Article > Backend Development > How to effectively shield PHP error prompts_PHP Tutorial
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.
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 nameE_ERRORE_WARNING
E_PARSEE_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_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)
.
http://www.bkjia.com/PHPjc/445954.html
true