<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Totti的部落格]]></title> 
<link>https://iam.ittot.com/index.php</link> 
<description><![CDATA[记录我的生活，收集我的收集]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Totti的部落格]]></copyright>
<item>
<link>https://iam.ittot.com/read.php/.htm</link>
<title><![CDATA[Cannot modify header information - headers already sent by错误解决办法]]></title> 
<author>Totti &lt;totti5116@163.com&gt;</author>
<category><![CDATA[收集]]></category>
<pubDate>Mon, 19 Oct 2009 05:10:46 +0000</pubDate> 
<guid>https://iam.ittot.com/read.php/.htm</guid> 
<description>
<![CDATA[ 
	在后台管理，用header("location:");做返回时，总是不能正常返回，<br/>Warning: Cannot modify header information - headers already sent by....<br/>这类语句，baidu了一下，才知道是setcookie在捣乱，以下是在网上找的一些资料：<br/><br/>方法一：<br/>在PHP里Cookie的使用是有一些限制的。<br/>1、使用setcookie必须在<html>标签之前<br/>2、使用setcookie之前，不可以使用echo输入内容<br/>3、直到网页被加载完后，cookie才会出现<br/>4、setcookie必须放到任何资料输出浏览器前，才送出<br/>.....<br/>由于上面的限制，在使用setcookie()函数时，学会遇到 "Undefined index"、"Cannot modify header information - headers already sent by"…等问题，解决办法是在输出内容之前，产生cookie，可以在程序的最上方加入函数 ob_start();<br/><br/>ob_start ：打开输出缓冲区<br/>函数格式：void ob_start(void)<br/>说明：当缓冲区激活时，所有来自PHP程序的非文件头信息均不会发送，而是保存在内部缓冲区。为了输出缓冲区的内容，可以使用ob_end_flush()或flush()输出缓冲区的内容。<br/><br/><br/>方法二：<br/>解决Warning: Cannot modify header information - headers already sent by ......<br/><br/>前几天装了个php的大头贴系统测试，发现报错Warning: Cannot modify header information - headers already sent by ......<br/>今天又装openads，还是出现这个问题。怒了。上网找了半天，有人说要在文件开头写上<br/>ob_start();<br/>失败。<br/>后来打开 php.ini 然后把 output_buffering 设为 on 。重起appache，OK。看来这才是解决办法。<br/><br/>特别注意：<br/>如果使用utf-8编码，一定要去掉UTF-8中的BOM，这都是因为utf-8编码文件含有的bom原因，而php4,5都是不支持bom的。去掉bom，可以用Notepad++打开转换一下。切记，切记，切记！（这问题害我折腾了半天。）<br/><br/>用PHP的ob_start();控制您的浏览器cache&nbsp;&nbsp;URL：<a href="http://hi.baidu.com/dandankai/blog/item/ca628e4448975f81b3b7dc02.html" target="_blank">http://hi.baidu.com/dandankai/blog/item/ca628e4448975f81b3b7dc02.html</a><br/>Tags - <a href="https://iam.ittot.com/go.php/tags/php/" rel="tag">php</a> , <a href="https://iam.ittot.com/go.php/tags/iis/" rel="tag">iis</a>
]]>
</description>
</item><item>
<link>https://iam.ittot.com/read.php/.htm#blogcomment</link>
<title><![CDATA[[评论] Cannot modify header information - headers already sent by错误解决办法]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://iam.ittot.com/read.php/.htm#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>