How to shield errors in php: 1. Add the @ symbol before any error statement; 2. Add "error_reporting(0);" to the first line of the PHP file; 3. Use the "display_errors" shielding method .
Recommended: "PHP Video Tutorial"
Shielding php errors
Method 1: @
Add the @ symbol before any error statement to block errors. For example:
<?php $u_name= @$_POST['u_name']; $u_pwd= @$_POST['u_pwd']; 方法二:error_reporting
Add in the first line of the PHP file: error_reporting(0); that is Maskable errors, for example:
<?php error_reporting(0);
Method 3: display_errors masking method
This method should be the most thorough solution, because the first two methods can only act on a single row or a single file, this applies to all php files. Open the php.ini file and search for display_errors = on. The default should be on, which means the error reporting function is enabled. Just change it to off.
The above is the detailed content of How to block errors in php. For more information, please follow other related articles on the PHP Chinese website!