错误:已发送标头

时间:2013-01-05 05:21:38

标签: php

  

可能重复:
  Headers already sent by PHP
  Reference - What does this error mean in PHP?

<?php
include 'connect.php';
include 'header.php';
?>      
<p>Mahtava is an organization dedicated to providing great services and web projects to people for free. We are passionate about the web and making it a better place for its citizens to live in. We have a strong emphasis on the user experience in whatever we do, and are focussed on keeping things the best for our users. Many of our projects are open source, and we always are inviting new developers to help with them or to develop projects of their own with us.</p>
<?php
include 'footer.php';
?>

上述代码有什么问题?它一直在给我

  

'警告:session_start()[function.session-start]:无法发送   会话缓存限制器 - 已发送的标头(输出始于   /home/u599980382/public_html/newsite/index.php:1)in   /home/u599980382/public_html/newsite/connect.php在第2行'。

它不会在任何其他页面上执行此操作,甚至不会在具有几乎相同的确切代码的页面上执行此操作(仅内容不同);它只在索引上执行此操作。提前感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:0)

尚未发送标头函数标头的使用 你可以检查一下  headers_sent

// If no headers are sent, send one
if (!headers_sent()) {
......
}

您可以将代码更改为此案例:

<?php
include 'header.php';
include 'connect.php';
include 'content.php';
?>