PHP inserts header (& #39; content-type: text/html; charset = & quot; UTF-8 & #39;) and error_reporting (),

Source: Internet
Author: User

PHP inserts header ('content-type: text/html; charset = "UTF-8 ') and error_reporting (),

1. header

PHP file insert header ("Content-type: text/html; charset = UTF-8 ");
Equivalent to <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">;
Objective: To prevent page garbled characters

2. error_reporting

Definition and usage: error_reporting () sets the PHP error level and returns the current level.
Function Syntax: error_reporting (report_level)
If the level parameter is not specified, the current error level is returned. The following items are possible values of level:
Value constant description

1: Fatal run error of E_ERROR. The error cannot be recovered. The script is paused. 2: E_WARNING runtime warning (non-fatal error ). Non-fatal running error. script execution will not stop. 4: parsing error during E_PARSE compilation. Parsing errors are only generated by the analyzer. 8: E_NOTICE runtime reminder (these are often caused by bugs in your code, and may also be caused by intentional behavior .) 16: Fatal error during initialization of E_CORE_ERROR PHP. 32: Warning during initialization (non-fatal error) during E_CORE_WARNING PHP startup ). 64: E_COMPILE_ERROR fatal error during compilation. This is like an E_ERROR generated by the Zend script engine. 128: warning when compiling E_COMPILE_WARNING (non-fatal error ). This is like an E_WARNING warning generated by the Zend script engine. 256: User-Defined error message for E_USER_ERROR. This is like a custom warning message by using the PHP function trigger_error (the programmer sets E_ERROR) 512: E_USER_WARNING. This is like a reminder message customized by the user using the PHP function trigger_error (an E_WARNING warning set by the programmer) 1024: E_USER_NOTICE. This is like a standardized warning by trigger_error using the PHP function (an E_NOTICE set for programmers) 2048: E_STRICT encoding. PHP is allowed to recommend how to modify the code to ensure the best interoperability forward compatibility. 4096: E_RECOVERABLE_ERROR indicates a fatal error. This is like an E_ERROR, but it can be captured through user-defined processing (see set_error_handler () 8191: all errors and warnings of E_ALL (excluding E_STRICT) (E_STRICT will be part of E_ALL as of PHP 6.0)

Any number of the above options can be connected with "OR" (OR |), so that all required levels of errors can be reported.
For example, the following code disables User-Defined errors and warnings, performs some operations, and then restores to the original error level:

<? Php // Disable Error Report error_reporting (0); // report error error_reporting (E_ERROR | E_WARNING | E_PARSE); // report all error error_reporting (E_ALL);?>

 

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.