: This article mainly introduces php error information configuration. if you are interested in the PHP Tutorial, refer to it. Error Echo, which is commonly used in development mode. However, many applications forget to disable this option in the formal environment. Error Echo can expose a large amount of sensitive information to facilitate the next attack. Disable this option.
Display_errors
Error Echo, which is commonly used in development mode. However, many applications forget to disable this option in the formal environment. Error Echo can expose a large amount of sensitive information to facilitate the next attack. Disable this option.
Display_errors = On
If an error occurs in the Enabled status, an error is returned.
Dispaly_errors = Off
If an error occurs, the system prompts "Server Error. But no error message appears.
Log_errors
Use this in the official environment and record the error information in the log. You can disable error echo.
For PHP developers, once a product is put into use, the first thing is to disable the display_errors option, this prevents hackers from attacking the paths, database connections, data tables, and other information exposed by these errors.
When a product is put into use, there will inevitably be error information. how can we record the useful information for developers?
Enable log_errors of PHP. by default, it is recorded in the log file of the WEB server, such as the error. log file of Apache.
Of course, you can also record the error log to the specified file.
# 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 to the operating system logs.
Display_errors = Off // display Chinese meaning is displayed, so display_error = off means no error is displayed!
Error_reporting sets the error message return level
2047 I remember it was E_ALL.
The php. ini file contains many configuration settings. You should have set your php. ini file and place it in the appropriate directory, as shown in instructions for installing PHP and Apache 2 on Linux (see references ). When debugging a PHP application, you should know two configuration variables. The two variables and their default values are as follows:
Display_errors = Off // disable all error messages. if it is ON, all error messages are displayed.
Error_reporting = E_ALL
E_ALL can be used to indicate all error information from poor coding practices to harmless prompts. E_ALL is a little too detailed for the development process, because it displays a prompt on the screen for some trivial matters (for example, the variable is not initialized), it will mess up the browser output
Therefore, we do not recommend that you use 2047. you 'd better change the default value to error_reporting = E_ALL &~ E_NOTICE
Solution for failure of display_errors = Off in PHP. ini
Problem:
In the PHP setting file php. ini, display_errors = Off is already set, but an error message still appears on the webpage during running.
Solution:
Check log_errors = On. according to the official statement, when log_errors is set to On, the error_log file must be specified. if the specified file is not specified or the specified file has no permission to write data, as a result, it will be output to a normal output channel, which will invalidate the specified Off display_errors and print the error message. Therefore, log_errors = Off will solve the problem.
Often seen error_reporting (7) meaning: Set the error message return level.
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
1 E_ERROR 2 E_WARNING 4 E_PARSE is displayed when an error occurs.
// Disable error reporting
Error_reporting (0 );
// Report running errors
Error_reporting (E_ERROR | E_WARNING | E_PARSE );
// Report all errors
Error_reporting (E_ALL );
?>
The above describes the php error information configuration, including the content, and hope to be helpful to friends who are interested in the PHP Tutorial.