当前位置:首页> PHP教程> PHP精通
关键字
文章内容
gb2312的php文件转换为utf-8格式后的一个错误
 
 
修改时间:[2009/01/23 11:51]    阅读次数:[881]    发表者:[起缘]
 
GB2312的php文件转换为UTF-8格式后,php程序运行时就会出现header已发送这样的错误提示(试图打开session的时候)。

错误如下:
代码:
Warning: Cannot modify header information - headers already sent by (output started at /home/yoyo/public_html/blog/index.php:1) in /home/yoyo/public_html/blog/global.php on line 11
?
Warning: Cannot modify header information - headers already sent by (output started at /home/yoyo/public_html/blog/index.php:1) in /home/yoyo/public_html/blog/global.php on line 35


这样的错误通常是在打开session之前页面已经有输出时出现,在IE下面看,并没有输出,可是在firefox下面看,在正式页面输出前,有一个字节的乱码。这个乱码就是造成错误的原因(它在session之前就输出了)。

解决的方法:找到你有出错提示的文件,下载下来,用编辑器(推荐用最新版的editplus)打开,拷贝代码,删除这个文件,重建一个新文件,复制刚才的代码进去,存文件的时候,一定要存成UTF-8的,上传覆盖原文件,应该就好了。