display_errors
Error echo is commonly used in development mode, but many applications forget to turn off this option in the official environment. Error echo can expose a lot of sensitive information, which facilitates the attacker's next attack. It is recommended to turn this option off.
display_errors = On
In the on state, if an error occurs, an error will be reported and an error message will appear
dispaly_errors = Off
In the off state, if an error occurs error, it will prompt: Server error. But no error message will appear
log_errors
Just use this in a formal environment and record the error information in the log. Just in time to turn off error echo.
For PHP developers, once a product is put into use, the first thing to do is to turn off the display_errors option to avoid being damaged by the path, database connection, data table and other information disclosed by these errors. to hacker attacks.
After a product is put into use, there will inevitably be error messages. So how to record this information that is very useful to developers?
Just turn on PHP's log_errors. By default, it is recorded to the log file of the WEB server, such as Apache's error.log file.
Of course, error logs can also be recorded to specified files.
Copy code The code is as follows:
# vim /etc/php.inidisplay_errors = Off
log_errors = On
error_log = /var/log/php-error.log
You can also set error_log = syslog to record these error messages in the operating system log.
display_errors = Off //display in Chinese means display, so display_error=off means not displaying errors!
error_reporting sets the level of error message reporting
2047 I remember it should be E_ALL.
There are many configuration settings in the php.ini file. You should have set up your php.ini file and placed it in the appropriate directory, as documented in the instructions for installing PHP and Apache 2 on Linux (see Resources). There are two configuration variables that you should be aware of when debugging PHP applications. The following are these two variables and their default values:
display_errors = Off //Turn off all error messages. When it is ON, all error messages are displayed.
error_reporting = E_ALL
E_ALL covers everything from bad coding practices to harmless tips to errors. E_ALL is a bit too detailed for the development process, because it also displays prompts on the screen for some small things (such as variables not being initialized), which will mess up the browser's output
so it is not recommended to use 2047, it is best to change the default value For: error_reporting = E_ALL & ~E_NOTICE
Solution to the failure of display_errors = Off in PHP.ini Problem: PHP settings file Display_errors = Off has been set in php.ini, but during operation, error messages still appear on the web page.
Solution: After checking log_errors=On, according to the official statement, when this log_errors is set to On, then the error_log file must be specified. If it is not specified or the specified file does not have permission to write, Then it will still be output to the normal output channel, which will invalidate the specified Off of display_errors, and the error message will still be printed. So set log_errors = Off and the problem is solved.
It is often seen that error_reporting (7) means: setting the level of error message reporting.
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
means 1 E_ERROR 2 E_WARNING 4 E_PARSE
Copy code The code is as follows:
//Disable error reporting
error_reporting(0);
//Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//Report all errors
error_reporting(E_ALL);
?>
http://www.bkjia.com/PHPjc/326045.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326045.htmlTechArticledisplay_errors Error echo is commonly used in development mode, but many applications forget to turn off this option in the formal environment. . Error echo can reveal a lot of sensitive information, which is...