Cannot modify header information headers already sent by

[php] 2024-04-28 圈点397

摘要:会出现如上的警示内容:Warning: Cannot modify header information - headers already sent by。查了很多资料,原因分析挺多

有时候,会出现如上的警示内容:

Warning: Cannot modify header information - headers already sent by。


查了很多资料,原因分析挺多:

1,在php程序的头部加了,header("content-type: text/html; charset=utf-8");之后页面就出现上面的错误。因为 header('Content-Type:text/html;charset= UTF-8');发送头之前不能有任何输出,空格也不行。


2,php.ini配置问题,找到output_buffering改为on或者任意一个数字,但尝试无结果。其本身就是on,估计不是这个问题。


3,加上ob_start()函數

有时候是进行了setcookie操作,或者是session操作等;

这个时候,在开始加上ob_start(); 在结尾加上ob_end_flush();



  

相关内容:

感谢反馈,已提交成功,审核后即会显示