PHP除开BOM头后出现乱码

WBOY
Release: 2016-06-13 11:19:05
Original
983 people have browsed it

PHP去除BOM头后出现乱码
程序用的是Notepad++文本编辑器编写的,当选择格式->以UTF-8格式编码后,中文字符(从数据库读取,存储到$_SESSION中)可以正常显示,但是会出现以下警告

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] => 张三 [userid] => 2009011105 [role] => 3 ) 

登录成功!
5秒钟后进行跳转

去掉BOM头后,警告消失,但是中文字符全部变成乱码

Array ( [username] => 寮犱笁 [userid] => 2009011105 [role] => 3 ) 
鐧诲綍鎴愬姛!
5绉掗挓鍚庤繘琛岃烦杞

求解决方法


------解决方案--------------------
header('Content-type: text/html; charset=utf-8');
Copy after login
加一句申明是UTF-8编码,不然浏览器可能会自己去检测
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!