PHP Open Error Prompt (detailed)

Source: Internet
Author: User
The first method: Change the value of Display_errors and error_reporting in the php.ini file, without directly adding
Display_errors = on
error_reporting = E_all | E_strict
Then: Restart Apache, end. (There are multiple versions of PHP, you may fail, for reasons, see the second method of interpretation)
Explain:
display_errorsError echo, commonly used to develop patterns, but many applications in the formal environment also forget to turn off this option. Error-Echo can expose a lot of sensitive information, which facilitates attackers ' next attack. It is recommended that you turn off this option. display_errors = onOpen state, if there is an error, then the error, there are errors prompted dispaly_errors = offIn the shutdown state, if there is an error, prompt: Server error. But no error message appears error_reportingThe parameters you can set are the following: The error report is a bit field. You can add numbers together to get the error reporting level you want. e_all– all errors and warnings (excluding e_strict) e_error– fatal run-time errors e_warning– Runtime warnings (non-fatal errors) e_parse– compile-time parsing errors e_notice– Run-time Reminders (these are often the A bug can be caused by an intentional action. e_strict– coding standardization Warning, which allows PHP to suggest how to modify the code to ensure optimal interoperability forward compatibility. Fatal error during e_core_error–php startup e_core_warning–php warning during initialization (Non-fatal fault) e_compile_error– compile-Time fatal errors e_compile_warning– compilation Time Warning (non-fatal) e_user_error– user-defined error message e_user_warning– user-defined warning message e_user_notice– user-defined reminder message
The second method: Add the following sentences to the Apache httpd.conf file
Php_flag display_errors on
php_value error_reporting 2039
Then: Restart Apache, end.
Explain:
Depending on what Apache is doing, opening the error report in PHP may not work because there may be multiple versions of PHP on the computer.
Sometimes it's hard to tell which PHP version the Apache is using, because Apache can only view one php.ini file.
It is a security issue not knowing which php.ini file Apache is using to configure itself.
However, there is a way to configure PHP variables in Apache to ensure that the correct error level is set.

also, it's best to know how to set these configuration variables on the server side to veto or preempt php.ini files, providing a higher level of security.

to do what you've done in the php.ini file, add the following lines to httpd.conf, overwriting any php.ini files:
php_flag display_errors on
php_value error_ Reporting 2039
This overrides the flag already set for display_errors in the php.ini file, and the error_reporting value.
The value 2039 represents E_all & ~e_notice.
If you prefer to use E_all, set the value to 2047.
Mutual Encouragement ~

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.