Example of configuring masking error information display and saving error logs in PHP.ini

  • 2021-06-28 11:35:46
  • OfStack

If errors occur during the running of PHP program, whether error information is displayed on the browser, and the level of error information is controlled during the development, debugging and operation of the program.
Here is how to control the shielding and display of PHP error information (errors) by setting php.ini:
1. Is error message displayed
 Display error  display_errors = On
      Shielding error  display_errors = Off ( Default value )

2. Level of display error information
error_reporting = E_ALL ( whole )
     error_reporting = E_ALL & ~E_NOTICE (Notice  The above errors will be displayed )

Here we set 1 as E_ALL, using error_in the PHP programThe reporting() function sets the level of error information for the current program.
3. Set whether to save the error log
We generally set the program to not show errors during operation so that we can record the running state by saving the error log
log_errors = On ( Log errors )
    log_errors = Off ( Do not record )

If you save the error log, you need to also set the error log to save the file
error_log = e:/php/logs/php_error.log

Related articles: