We know that the production environment of the product is definitely not incorrectly displayed, so:
Change display_errors = Off to display_errors = On in php. ini.
Or ini_set ('display _ errors ', 0 );
Secondly, we know that the php error level is controlled by error_reporting [error_reporting detailed tutorial], but many people disable the error message in the production environment.
Error_reporting (0 );
In fact, this practice is not scientific in my opinion. It is like this in the codeigniter framework.
The code is as follows: |
Copy code |
If (defined ('enable ')) { Switch (ENVIRONMENT) { Case 'development ': Error_reporting (E_ALL ); Break; Case 'testing ': Case 'production ': Error_reporting (0 ); Break; Default: Exit ('The application environment is not set correctly .'); } } |
Online error information must be recorded. error_reporting (0) will not record all error information. It should be: error_reporting = E_ALL &~ E_NOTICE: as long as display_errors = Off, the error message will not be displayed on the page, because display_errors has a higher priority.
Note:
If php. log_errors = On in ini. According to the official statement, the error_log file must be specified. If the specified file is not specified or the specified file does not have the write permission, the file will still be output to the normal output channel, in this case, the specified Off of display_errors is invalid, and the error message is printed. Set log_errors to Off.
In summary, the following error logs can be recorded for unrealistic error information in the production environment:
The code is as follows: |
Copy code |
<? Php /** * Records production environment error logs * * @ Link http://www.111cn.net */ Error_reporting (E_ALL ); Ini_set ('display _ errors ', 0 ); Ini_set ('log _ errors ', 1 ); Ini_set ('error _ log', 'E: \ '.date('y-m-d'{.'_phpddt.com.txt ');
|