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.