Warning: session_start () Solution

Source: Internet
Author: User
Tags php session

Recently playing discuz! X's dx1.5, found no WAP version, AD address m.home118.com, the result is no problem in windows, upload liunx server appears as follows:

 

Warning: Session_start () [function. Session-start]: cannot send session cache limiter-headers already sent (output started ......

 

--------------------------------------------------------------

 

It is obvious that there is output in front of the session, but there seems to be no output in the front. The reason is as follows:

After editing in notepad, the BOM information is at the beginning of the code file that is saved as UTF-8 encoding, And the BOM information is a hidden string of characters at the beginning of the file, used to let some editors recognize that this is a UTF-8-encoded file.

PHP did not consider the BOM issue during design (maybe the Founders do not like Windows ),That is to say, he will not ignore the three characters of BOM starting with a UTF-8-encoded file (in hexadecimal notation, the viewing starts with ef bb bf ).

So when you use notepad or dw (DW encoded as utf8) to open the file, there is nothing in front of it.

However, an error is reported because BOM information is output, but PHP session cannot be output.

Glossary:

One Unicode SpecificationBom Concept. Bom -- byte order mark, which is a mark of the byte order. Here is a description of BOM:

There is a character named "Zero Width no-break space" in the UCS encoding, and its encoding is feff. Fffe does not exist in the UCs, so it should not appear in actual transmission. We recommend that you transmit the character "Zero Width no-break space" before transmitting the byte stream in the UCS specification ". In this way, if the receiver receives feff, it indicates that the byte stream is big-Endian; if it receives fffe, it indicates that the byte stream is little-Endian. Therefore, the character "Zero Width no-break space" is also called Bom.

The UTF-8 does not need BOM to indicate the byte order, but BOM can be used to indicate the encoding method. The UTF-8 code for the character "Zero Width no-break space" is ef bb bf. So if the receiver receives a byte stream starting with ef bb bf, it will know that this is UTF-8 encoding.

Windows uses BOM to mark the encoding of text files.

In addition, the Unicode website FAQ-BOM detailed Bom. The natural authority of the official website is only in English, and it looks hard.

Bom occupies three bytes of the UTF-8-encoded file. If you use NotePad to save a text file as a UTF-8 encoding method, open the file with ue, switch to the hexadecimal editing status, you can see the beginning of fffe. This is a good way to identify the UTF-8 encoding file, the software through BOM to identify whether the file is UTF-8 encoding, many software also requires that the file to be read must carry Bom. However, there are still a lot of software that cannot recognize Bom. When I was studying Firefox, I knew that in earlier versions of Firefox, BOM was not available for extensions, but later versions of Firefox 1.5 began to support Bom. Now, PHP does not support Bom.

 

Solution:

1. Do not use NotePad to save the UTF-8 format;

2. Use ultredit to store data in the "UTF-8 without Bom" format.

 

 

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.