灾难恢复和true CDP解决方案-EchoStream for AIX

查看完整版本: PHP技巧教程:setcookie语句的问题

yuki_365170a716 2008-8-11 09:50

PHP技巧教程:setcookie语句的问题

<P>出现的错误提示: </P>
<P>Warning: Cannot modify header [url=http://whatis.ctocio.com.cn/searchwhatis/11/6025511.shtml]information[/url] - headers already sent by </P>
<P>解决办法: </P>
<P>打开php_ini,搜索output_bufferfing,把前面的分号去掉,把off修改为on,或者设置一个数值。就可以了。 </P>
<P>这类语句,造成这个原因是因为setcookie语句的问题。 </P>
<P>[url=http://whatis.ctocio.com.cn/searchwhatis/425/5947425.shtml]cookie[/url]本身在使用上有一些限制,例如:<BR>1.呼叫setcookie的?述必?放在标签之前<BR>2.呼叫setcookie之前,不可使用echo<BR>3.直到??被重新?入後,cookie才?在程式中出?<BR>4.setcookie函数必?在任何?料?出至浏览器前,就先送出<BR>5.…… </P>
<P>基於上面?些限制,所以?行setcookie()函数时,常?碰到”Undefined index”、”Cannot modify header information - headers already sent by”…等??,解?”Cannot modify header information - headers already sent by”这个??的方法是在产生cookie前,先延缓?料输出至浏览器,因此,您可以在程式的最前方加上ob_start();这个函?。这样就可以解决了。</P>
页: [1]
查看完整版本: PHP技巧教程:setcookie语句的问题