How to block all errors in php.ini: 1. Open the "php.ini" configuration file and search for the "display_errors" item in it; 2. Set the value of the "display_errors" item to "Off". All PHP error reporting can be turned off, thereby blocking all errors.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Shield all errors in php.ini Method:
Open the php.ini configuration file, search for display_errors in it, and then set the value of display_errors to Off to turn off all PHP error reports. As shown below:
; This directive controls whether or not and where PHP will output errors, ; notices and warnings too. Error output is very useful during development, but ; it could be very dangerous in production environments. Depending on the code ; which is triggering the error, sensitive information could potentially leak ; out of your application such as database usernames and passwords or worse. ; For production environments, we recommend logging errors rather than ; sending them to STDOUT. ; Possible Values: ; Off = Do not display any errors ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) ; On or stdout = Display errors to STDOUT ; Default Value: On ; Development Value: On ; Production Value: Off ; http://php.net/display-errors display_errors = Off
This method should be the most thorough solution, because it applies to all PHP files.
Extended knowledge: Other ways to mask errors
Use the error control operator: @
PHP supports the use of the error control operator @. Place it before a PHP expression and any error messages the expression may produce will be ignored.
If a custom error handling function is set with set_error_handler(), this error handling function will still be called, and if @ is used before the error statement, the error handling function will return 0.
It should be noted that the @ operator is only valid for expressions. Simply put, if you can get a value from somewhere, you can add the @ operator in front of it. For example, the @ operator can be used before variables, functions, include calls, constants, etc., but it cannot be placed before the definition of a function or class, nor can it be used before conditional structures such as if and foreach statements. The
@ operator is also effective for serious errors that can cause the program to terminate. This means that if @ is used to suppress the error message before a function call that does not exist or has the wrong letter, the program will Die there without any hint.
[Example] Use the @ error control operator to mask errors in the code.
<?php $link = @mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db") or die('数据库连接失败!'); ?>
The running results are as follows:
数据库连接失败!
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to block all errors in php.ini. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.