2

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

<?php 
include_once 'session.php';
$uid='0';
error_reporting(E_ALL); ini_set('display_errors', 'On'); 
if($uid=='0' or empty($uid) or $uid=='')
{
header("Location:index.php");
exit;
}
include_once 'top.php';
?>

我的 session.php 如下。它甚至不输出一个字。

 <?php error_reporting(0);// Turn off all error reporting
if (!isset($_SESSION)) {
session_start();
}
if(isset($_SESSION['uid']))
{
    $uid=$_SESSION['uid'];
    $sid='0';
}
else
{
    $uid='0';
    $sid='0';
}
?>

在上面的代码中,我得到如下错误

Warning: Cannot modify header information - headers already sent by 
(output started at /home/content/41/9717441/html/session.php:1) 
in /home/content/41/9717441/html/ask.php on line 7

我在代码中做错了吗?

4

2 回答 2

3

也许你在像这样的 php 打开标签之前在 session.php 中有一个空格输出

 [space]<?php
 ....
于 2012-08-11T12:30:31.660 回答
0

session.php输出一些东西。在发送标题之前,您不能输出文档的正文。

于 2012-08-11T12:26:20.643 回答