How to hide error information in php: 1. Add the @ symbol before the error statement; 2. Modify "display_errors=on" to off; 3. Use the function "display_errors" to turn off error display.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to hide error messages in php?
How to shield errors and prompts in php
1. As long as you add the @ symbol before the error statement, the error message can be blocked;
Example:
@unlink('./image.png');
2. Open the php.ini file and search for "display_errors = on". The default is on, change it to off;
3. Use the function "display_errors" to turn off the error display;
Content supplement:
Shield PHP error prompts
Method 1: Add @ before the function that may cause errors, and then or die("")
such as :
@mysql_connect(...) or die("Database Connect Error")
Method 2: Edit php.ini, search for "display_errors =", and change the value after "=" to "off.
Method 3: Add error_reporting( before the php script 0), shield all error prompts.
Among them, error_reporting configures the level of error information reporting.
Syntax: int error_reporting(int [level]);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to hide error messages in php. For more information, please follow other related articles on the PHP Chinese website!