Modify PHP.ini to achieve masking error messages and log _php tips

Source: Internet
Author: User
That is because the php.ini turned off the error display, the error written in the file, this is the result of artificial settings, Display_errors =on is good.
However, error-safe points are not displayed, it is recommended to open when debugging, and then shut down when providing the service.

To provide you with a little information:

Display_errors = On

PHP defaults to open error message display, we change it to:

Display_errors = Off

When the error display is turned off, the PHP function does not display the wrong information to the user, which in some way prevents the attacker from knowing the physical location of the script from the error message, as well as some other useful information, at least causing a certain obstacle to the attacker's black box detection. These error messages may be useful to us and can be written to the specified file, then modify the following:

Log_errors = Off

To

Log_errors = On

and the specified file, locate the following line:

; error_log = filename

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

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

So all the mistakes will be written in the Php_error.log file.

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

Error_reporting
Configure the level of error message return.
Syntax: int error_reporting (int [level]);
return value: Integer
Function type: PHP system function

This function is used to configure the level of error message return, which is a bit mask (bitmask) for an integer, as shown in the following table.
Mask value indicates name
1 E_error
2 e_warning
4 E_parse
8 E_notice
E_core_error
E_core_warning

E_notice indicates that the general situation is not logged and is only used when the program has an error condition, such as attempting to access a nonexistent variable, or calling the stat () function to view files that do not exist.
E_warning are usually displayed but do not interrupt the execution of the program. This is very effective for debugging. For example, call Ereg () with a problematic regular expression.
E_error are usually displayed and interrupt the execution of the program. This mask will not be able to trace the memory configuration or other errors.
E_parse parse the error from the 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 the PHP core error warning.
————————————
Extra:
1.
In the PHP file
Error_reporting (7) of which 7 is 1+2+4, that is, return 1 E_error 2 e_warning 4 e_parse
2.
In php.ini
Display_errors = off//default is off error prompt
error_reporting = e_all//display all information from bad coding practices to harmless hints to errors, because the information in return is too fine-grained, including harmless information, to be able to see actual prompts during the development process, the recommended configuration is 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.