PHP output Web page source code inexplicably a lot of strange boxes, resulting in Ajax validation failed.

Source: Internet
Author: User

Today in the use of an AJAX authentication user name function, the return value error, grabbed the packet looked under, more out of a pile of points, the source code shows a box and 6 blank lines

This pile of things lead to Ajax judgment return value will be wrong, degree Niang an afternoon (Emperor not negative game people AH), originally is a pit Dad's BOM header file.

The solution is to use the Ob_clean () function before the output to clear;

Remember not to use Notepad to open UTF8 encoded PHP files. This problem is prone to occur

Below is the degree Niang explanation.

Bom--byte order mark, the Chinese name translated "byte order Mark". Here is a description of the BOM: in the UCS code is called "Zero width no-break Space", the Chinese translation masterpiece "0 wide uninterrupted interval" character, its encoding is FEFF. FFFE is not a character in UCS, so it should not appear in the actual transmission. The UCS specification recommends that the character "Zero Width no-break Space" be transmitted before the byte stream is transmitted. This means that if the recipient receives FEFF, the byte stream is Big-endian, and if Fffe is received, it indicates that the byte stream is Little-endian. So the character "zero width No-break space" ("0 wide uninterrupted interval") is also called a BOM. The utf-8  does not require a BOM to indicate byte order, but it can be used to indicate the encoding using a BOM. The UTF-8 code for the character "Zero Width no-break Space" is the EF BB BF. So if the receiver receives a byte stream beginning with the EF BB BF, it knows that this is UTF-8 encoded. Windows uses a BOM to mark the way a text file is encoded. Character U+feff if it appears at the beginning of a byte stream, it is used to identify the sequence of bytes in the stream, whether the high is in front or low. If it appears in the middle of the byte stream, the meaning of the 0-width non-wrapping space is expressed, and the user looks like a space. Starting with Unicode3.2, the U+feff can only appear at the beginning of the byte stream, and can only be used to identify the sequence of bytes, as its name-the byte-order tag-is represented, except that the usage has been discarded. Instead, use u+2060 to express a 0-width, non-breaking space.software such as Windows-brought Notepad, when saving a UTF-8 encoded file, inserts three invisible characters (0xEF 0xBB 0xBF, or BOM) where the file begins. It is a string of hidden characters that allows editors such as Notepad to identify whether the file is encoded in UTF-8. For general files, this does not cause any trouble. but for PHP, BOM is a big hassle. PHP does not ignore the BOM, so when you read, include, or reference these files, the BOM is used as part of the text at the beginning of the file. Depending on the characteristics of the embedded language, this string of characters will be executed directly (shown). As a result, even if the top padding of the page is set to 0, there is no way to keep the entire page close to the top of the browser, because there are 3 characters at the beginning of the HTML!

PHP output Web page source code inexplicably a lot of strange boxes, resulting in Ajax validation failed.

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.