标题已经发送,找不到空白或html输出


Headers already sent, cant find white space or html output

得到这个错误…通常情况下,在php/headers发送之前,它会与一个空格/output相关联,但不能到达这个的底部。

所以错误是:

Warning: Cannot modify header information - headers already sent by 
(output started at
/Applications/MAMP/htdocs/website/index.php:11) in 
/Applications/MAMP/htdocs/website/process/checkautologin.php on line 65
Warning: Cannot modify header information - headers already sent by 
(output started at /Applications/MAMP/htdocs/website/index.php:11) 
in /Applications/MAMP/htdocs/website/process/checkautologin.php on line 120

索引PHP看起来像这样在顶部:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>BuildSanctuary</title>
    <?php
    require 'init.php';
    ?>

第11行是开始的php标记。

第65行check auto login是:

setcookie ("cookie",0,time() -3600,'/');

及其周围代码为:

// 'login' the user by setting the usual sessions
$_SESSION['user'] = $usernameuser;
$_SESSION['userid'] = $userid;
$_SESSION['logged'] = "1";
setcookie("cookie",0,time() -3600,'/');
// query the database to try and find a mactching row:
$query = " DELETE FROM `remember_me` WHERE `token` = :token "; 
// Create bound values
$query_params = array( 
  ':token' => $row['token'],
); 

下面的部分:

// set new cookie
setcookie ("cookie",$new_cookie_val,time() + (10 * 365 * 24 * 60 * 60),'/');
} 
catch(PDOException $ex) 
{   <-- this is line 120.           
}

任何想法?

错误:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>BuildSanctuary</title>
    <?php
    require 'init.php';
    ?>

正确的:

<?php
require 'init.php';
?>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>BuildSanctuary</title>