PHP headers already sent(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 标头已发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 标头已发送


基础教程推荐
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01