PHP 标头已发送 [英] PHP headers already sent

查看:22
本文介绍了PHP 标头已发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
已由 PHP 发送的标头

得到以下错误:

"Warning: Cannot modify header information - headers already sent by (output started at..."

对于以下行:

echo '<center>Current Time is '. gmdate("H:i A") . ' GMT (Greenwich Mean Time or UTC)<br />';

如果我将其注释掉,它只会在下一个 echo 语句中抛出错误.思考为什么 PHP 如此讨厌我的 echo 语句?

If I comment it out it just throws up the error at the next echo statement. Thoughts on why PHP hates my echo statements so much?

这是我在 HTML 底部的包含:

Here is my include toward the bottom of the HTML:

<div id="saveCanForm" width="100%">
<?php include('savereport.php'); ?>
</div>

推荐答案

问题不在于 echo 语句.看起来您在文件的稍后位置有一个 header 调用,但是一旦输出任何文本,您就无法发送标题.您可以将标头移动到脚本的开头,也可以使用输出缓冲.

It's not the echo statements that are the problem. It looks like you have a header call somewhere later in the file, but you can't send headers once you output any text at all. You could either move the headers to the beginning of the script or alternatively use output buffering.

这篇关于PHP 标头已发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆