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

How to block all errors in php

藏色散人
藏色散人Original
2021-03-26 09:22:162577browse

How to shield all errors in php: 1. Add the @ symbol before the error statement; 2. Open the php.ini file and change the value of "display_errors=on" to off; 3. Use the function "display_errors" "Turn off the error display.

How to block all errors in php

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

How to block errors 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 error display;

Content supplement:

Shield PHP error prompts

Method 1: Add @ before the function that may cause errors, and then or die("")

For example:

@mysql_connect(...) or die("Database Connect Error")

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

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

Among them, error_reporting Configure the level of error message reporting.

Syntax: int error_reporting(int [level]);

Return value: integer

Function type: PHP system function

[Recommended learning: PHP video tutorial]

The above is the detailed content of How to block all 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
Previous article:Steps to upload php filesNext article:Steps to upload php files