无法在 PHP 中重定向页面


unable to redirect a page in PHP

可能的重复项:
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';
?>

我的会议.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

我在代码中做错了什么吗?

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

 [space]<?php
 ....

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