PHP’s error echo provides a lot of convenience for code debugging, allowing us to quickly find the error. However, sometimes displaying error messages will expose some sensitive information and have a negative impact on program security. Therefore, through the php.ini configuration file, we can turn it off when not debugging the program. The method is as follows:
Open PHP.ini, find display_errors, change the following value to off, and set error_reporting to E_ALL. As shown below:
display_errors = Off
error_reporting = E_ALL
The following is also possible:
display_errors = Off
error_reporting = E_ALL & ~E_NOTICE
Note: If setting display_errors = Off does not work, please set log_errors to Off. According to PHP official information, when log_errors is set to On, the error_log file must be specified. If it is not specified or the specified file does not have write permission, display_errors=Off will also be invalidated, and the error message will still be displayed, so, log_errors = Off, the problem is completely solved.