session_start()和header('location:')重定向

ner*_*ama 3 php

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

我有一个问题session_start(),并header('Location:')在注销PHP文件.

我正在使用html文件中的简单锚标记链接到注销文件.注销php文件是这样的:

<?php
session_start();
session_destroy();
header("Location: index.php");
?> 
Run Code Online (Sandbox Code Playgroud)

要查看我使用的错误,

error_reporting(E_ALL);
ini_set('display_errors', '1');
Run Code Online (Sandbox Code Playgroud)

我收到一条警告"警告:session_start():无法发送会话缓存限制器 - 已经发送的标头"在第4行(在哪里session_start();)和警告:无法修改标头信息 - 已经在第6行发送的标头(在哪里header('Location')).

我已经看过其他有类似问题的人了.我确定之前没有空格session_start().在它之前没有输出任何东西.我试过只设置session_start()它还没有设置.我试过缓冲它ob_start().我尝试了重定向的相对和绝对路径,以确保.但没有任何效果.

我错过了什么吗?任何帮助深表感谢.

gal*_*hen 9

检查BOM

http://en.wikipedia.org/wiki/Byte_order_mark

在notepad ++ - 编码 - > utf8没有BOM

编辑

只是评论 - 你应该使用退出; 在标题("位置...")之后,确保没有其他内容可以运行,如http://php.net/manual/en/function.header.php中所建议的那样