Detail the closing method of the PHP error prompt

  • 2020-06-19 09:55:56
  • OfStack

The easiest way to do this is to simply add the following code to the php program code:

error_reporting(E_ALL^E_NOTICE^E_WARNING);

You can turn off all notice and warning level errors.

You can control the output by placing this statement in your script's utility include file, usually config.php or conn.php.

Of course I could have set it in php.ini as follows

Open the ES22en. ini file in the PHP installation directory

Find display_errors = On change to display_errors = off

. Note: if you have the PHP ini file to windows directory, then you must at the same time c: windows/php ini display_errors = On in modified to display_errors = off

PHP. ini display_errors = Off failure resolution

Question:

Although display_errors = Off has been set in the PHP Settings file php.ini, error messages still appear on the web page during the run.

Solution:

Open the ES69en.ini file in the PHP installation directory

Find log_errors = off change to log_errors = on

error_log = filename = error_log="D: PHPerrlogphp_error.log"

. Note: if you have the PHP ini file to windows directory, then you must at the same time c: windows/php ini file.

In addition, php_ES106en.log must have at least USER modify and write permissions, otherwise the error log cannot be output.


It is common to see error_reporting (7) meaning: to set the level of return for error messages.

value constant
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
64 E_COMPILE_ERROR
128 E_COMPILE_WARNING
256 E_USER_ERROR
512 E_USER_WARNING
1024 E_USER_NOTICE
2047 E_ALL
2048 E_STRICT

However, 7 = 1 + 2 + 4
E_ERROR 2 E_WARNING 4 E_PARSE


<?php
// Disable error reporting 
error_reporting(0);
// Report runtime errors 
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Report all errors 
error_reporting(E_ALL);
?>


Related articles: