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 标头已发送
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
