Home > php教程 > php手册 > body text

Warning: Cannot modify header information - headers already sent by

WBOY
Release: 2016-05-25 16:52:18
Original
1909 people have browsed it

如果在执行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. 用输出缓存来解决:

<?php
... HTML codes ... 

... PHP codes ... 
header ("Location: ...."); 
ob_end_flush(); 
?>
Copy after login

               
               

永久地址:

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!