How to block errors in php

藏色散人
Release: 2023-03-06 15:32:02
Original
3192 people have browsed it

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
Copy after login

Add in the first line of the PHP file: error_reporting(0); that is Maskable errors, for example:

<?php
error_reporting(0);
Copy after login

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!

Related labels:
php
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