PHP garbled code after removing the BOM header-php Tutorial

Source: Internet
Author: User
PHP removed the BOM header after the garbled program is written in Notepad ++ text editor, when the choice of format-> in UTF-8 format after encoding, Chinese characters (read from the database, stored in $ _ SESSION) can be displayed normally, but the following warning will appear:

Warning: session_start () [function. session-start]: Cannot send session cache limiter-headers already sent (output started at E: \ wamp \ www \ biyesheji \ login_check.php: 1) in E: \ wamp \ www \ biyesheji \ login_check.php on line 1

Warning: Cannot modify header information-headers already sent by (output started at E: \ wamp \ www \ biyesheji \ login_check.php: 1) in E: \ wamp \ www \ biyesheji \ login_check.php
Array ([username] => Zhang San [userid] => 2009011105 [role] => 3)

Login successful!
Jump in 5 seconds

After the BOM header is removed, the warning disappears, but all Chinese characters are garbled

Array ([username] => Users ?? [Userid] => 2009011105 [role] => 3)
? ????!
5. Why ????? Chen? Annoying

Solution


Reply to discussion (solution)

header('Content-type: text/html; charset=utf-8');
Add one statement is UTF-8 encoding, or the browser may detect it on its own

PHP code? 1 header ('content-type: text/html; charset = utf-8 '); add a statement that is UTF-8 encoding, otherwise the browser may detect it on its own
Solved. thank you.

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.