欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

Warning: Cannot modify header information - headers already sent by

程序员文章站 2022-05-21 13:03:37
...
如果在执行php程序时看到这条警告:"Warning: Cannot modify header information - headers already sent by ....".

有以下几种解决方法:

1. Blank lines (空白行):

,检查 后面没有空白行,特别是include或者require的文件.不少问题是这些空白行导致的。

2. Use exit statement (用exit来解决):在header后加上exit();

header ("Location: xxx");exit();

3.用Javascrīpt来解决:

self.location( file.php );"; ?>

可以用Javascrīpt来代替header。另外需要注意,采用这种方法需要浏览器支持Javascrīpt.

4. 用输出缓存来解决:


永久地址:

转载随意~请带上教程地址吧^^