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 标头已发送


- 没有作曲家的 PSR4 自动加载 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Laravel 仓库 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01