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');
加一句申明是utf-8编码,不然浏览器可能会自己去检测