Home  >  Article  >  Backend Development  >  How to cancel warning in php

How to cancel warning in php

藏色散人
藏色散人Original
2021-03-18 10:10:053464browse

php method to cancel warnings: 1. Add "ini_set("display_errors", "Off");" at the beginning of the php page; 2. Add the @ symbol before functions that may cause errors; 3. , add "error_reporting(0)" before the php script to block all error prompts.

How to cancel warning in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php ignore the warning warning prompt, personal test 100% effective

This tutorial teaches you how to turn off the Warning warning in the php file

You may encounter warnings during the php encoding process. When it is finally put into use, if you want Turn off warnings

Method 1: Add

error_reporting(E_ERROR); 
ini_set("display_errors", "Off");

at the beginning of the php page There are several other methods, such as turning off all warnings

Edit php.ini , search for "display_errors =" and change the value after "=" to "off.

Method 2:

Add @ before the function that may cause errors, and then or die("" ) Such as: @mysql_connect(...) or die("Database Connect Error")

For example:

Ignore the error in the statement after @

@$a = $b['a'];

Ignore the error in the statement after @, it is recommended to use this sentence. Because the error occurs in the array $b, so the @ symbol can be in front of $b. This is where the error really occurs.

$a = @$b['a'];

Method 3:

Add error_reporting(0) before the php script to block all error prompts.

<?php
error_reporting(0)
?>

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to cancel warning 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