Home  >  Article  >  Backend Development  >  How to block errors in php

How to block errors in php

藏色散人
藏色散人Original
2020-10-10 09:37:173147browse

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 .

How to block errors in php

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[&#39;u_name&#39;];
$u_pwd= @$_POST[&#39;u_pwd&#39;];
方法二: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!

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