这个问题在这里已经有了答案:
9年前关闭。
Possible Duplicate:
Headers already sent by 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
我在代码中做错了什么吗?
最佳答案
也许你在 php open 标签之前在 session.php 中有一个空格输出,像这样
[space]<?php
....
关于php - 无法在 PHP 中重定向页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11914675/