PHP error message Configuration

Source: Internet
Author: User
Tags configuration settings php error
Error echo, common term development mode, but many applications in the formal environment also forgot to turn off this option. Error echo can expose a lot of sensitive information to facilitate attackers ' next attack. It is recommended to turn this option off

Display_errors
Error echo, common term development mode, but many applications in the formal environment also forgot to turn off this option. Error echo can expose a lot of sensitive information to facilitate attackers ' next attack. It is recommended to turn this option off.
Display_errors = On
On the state, if there is an error, the error message, there are errors
Dispaly_errors = Off
Off state, if an error occurs, the prompt: Server error. But there are no error prompts
Log_errors
Use this in a formal environment and keep the error message in the log. The error echo can be turned off exactly.
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 hackers being hacked by the paths, database connections, data tables, and other information that these errors reveal.
When a product is put into use, there will inevitably be error messages, so how do you document these useful information for developers?
The PHP log_errors is turned on, by default it is logged to the Web server's log file, such as Apache's Error.log file.
Of course, the error log can also be logged to the specified file.

# vim/etc/php.inidisplay_errors = Off
Log_errors = On
Error_log =/var/log/php-error.log

Alternatively, you can set error_log = syslog to log these error messages to the operating system.
display_errors = Off//display Chinese meaning is display so display_error=off means not to show errors!
Error_reporting set the level of error message return
2047 I remember it was e_all.
There are many configuration settings in the php.ini file. You should have your own php.ini file set up and put it in the appropriate directory, as shown in the documentation for installing PHP and Apache 2 on Linux (see Resources). When debugging a PHP application, you should know two configuration variables. The following are the two variables and their default values:
Display_errors = off//Turns off all error messages, and all error messages are displayed when on.
error_reporting = E_all
E_all can be from bad coding practices to harmless prompts to all information that goes wrong. E_all is a bit too thin for the development process because it shows hints on the screen for small things (such as variables not initialized), which can mess up the browser's output
So it is not recommended to use 2047, it is best to change the default value to: error_reporting = E_all & ~e_notice
Resolution of display_errors = off failure in php.ini
Problem:
PHP settings file php.ini has been set display_errors = Off, but during the run, the page will still appear error message.
Solve:
After checking log_errors= on, according to the official statement, when this log_errors is set to ON, then you must specify the Error_log file, if not specified or the specified file does not have permission to write, so will output to the normal output channel, then also makes the Display_ Errors this specified off fails, the error message is printed out. So the log_errors = Off, the problem is solved.
Often see error_reporting (7) straight meaning: Set the level of error message return.
Value constant
1 E_error
2 e_warning
4 E_parse
8 E_notice
E_core_error
E_core_warning
E_compile_error
E_compile_warning
E_user_error
E_user_warning
1024x768 E_user_notice
2047 E_all
2048 e_strict
However 7=1+2+4
It's just a mistake. 1 e_error 2 e_warning 4 e_parse

disabling error Reporting
error_reporting (0);
Report Run-time errors
Error_reporting (E_error | e_warning | E_parse);
Report All Errors
Error_reporting (E_all);
?>

The above describes the PHP error message configuration, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.