得到";报头已经发送”;使用Facebook PHP api


Getting "headers already sent" with Facebook PHP api

当我尝试加载页面时,不断收到警告。。。

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/blazecra/public_html/matt/header.php:23) in /home/blazecra/public_html/matt/facebook/facebook.php on line 37

这是我的header.php文件

<?php
echo '<html>
<head>
    <title>MyGag - The Home of Gagging!</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
    <img src="img/nav.png" height="50" width="1000">
<div id="logo">
    <a href="index.php"><img src="img/logo.png" height="50" width="150"></a>
</div>
';
?>

在facebook php的第37行上只有

session_start();

你知道为什么会这样吗?

好的,它说在这个header.php的某个地方有输出,我知道我在回显,但那只是html。

如果你理解我的话,我怎么能不退货呢?

在发送完所有输出后,不能执行session_start

就像错误所说的:它不能发送cookie,因为已经发送了一个allready标头。无论何时开始发送数据,都必须(并且将)首先发送标头。

在调用该函数之前,请确保没有向用户发送任何输出。