Modify php. ini to shield error information and record logs

Source: Internet
Author: User

This is because the error display is disabled in php. ini and the error is written as a file. This is the result of human setting. display_errors = on.
However, the error is not displayed. We recommend that you enable it during debugging and disable it when providing services.

Provide you with some information:

Display_errors = On

By default, the error message is displayed in php. We will change it:

Display_errors = Off

After the error display is disabled, the php function execution error information will not be displayed to the user. This will prevent attackers from learning the physical location of the script from the error information to a certain extent, as well as some other useful information, at least it may cause some obstacles to the attacker's black box detection. These error messages may be useful to us and can be written to a specified file. Modify the following:

Log_errors = Off

Changed:

Log_errors = On

And the specified file. Find the following line:

; Error_log = filename

Remove the comment and change filename to the specified file, such as/usr/local/apache/logs/php_error.log.

Error_log =/usr/local/apache/logs/php_error.log

In this way, all errors will be written to the php_error.log file.

==========================================

Error_reporting
Configure the error message return level.
Syntax: int error_reporting (int [level]);
Return Value: integer
Function types: PHP system functions

This function is used to configure the error message return level. The level parameter is an integer bitmask. See the following table.
Mask Value
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING

E_NOTICE indicates that it is not recorded in general cases and used only when the program has an error, for example, an attempt to access a non-existent variable or call the stat () function to view a non-existent file.
E_WARNING is usually displayed, but the execution of the program is not interrupted. This is effective for debugging. For example, call ereg () with a problematic regular expression ().
E_ERROR is usually displayed and the program execution is interrupted. This mask cannot be used to trace memory configurations or other errors.
E_PARSE parsing errors from syntax.
E_CORE_ERROR is similar to E_ERROR, but does not include errors caused by the PHP core.
E_CORE_WARNING is similar to E_WARNING, but does not include PHP core error warnings.
------------
Additional:
1.
PHP File
Error_reporting (7) where 7 is 1 + 2 + 4, that is, return 1 E_ERROR 2 E_WARNING 4 E_PARSE
2.
Php. ini
Display_errors = Off // the error message is disabled by default.
Error_reporting = E_ALL // display all information from bad code practices to harmless prompts to errors, because the returned information is too detailed, including harmless information, to see the actual prompt during the development process, we recommend that you set it to error_reporting = E_ALL &~ E_NOTICE

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.