Php 标题已在Web服务器上发送-但不在本地主机上,相同的脚本

Php 标题已在Web服务器上发送-但不在本地主机上,相同的脚本,php,Php,Heyo,基本上是这样的:在我的本地Web服务器上,它工作正常,没有错误等。但是当我尝试在我的Web服务器上使用脚本时,我得到以下错误: Warning: Cannot modify header information - headers already sent by (output started at /home/namehere/public_html/index.php:5) in /home/namehere/public_html/steamauth/steamauth.php

Heyo,基本上是这样的:在我的本地Web服务器上,它工作正常,没有错误等。但是当我尝试在我的Web服务器上使用脚本时,我得到以下错误:

Warning: Cannot modify header information - headers already sent by (output started at /home/namehere/public_html/index.php:5) in /home/namehere/public_html/steamauth/steamauth.php on line 17
下面是steamauth.php的第17行及其周围的行:

 $openid = new LightOpenID('localhost');
    if(!$openid->mode) {
        if(isset($_GET['login'])) {
            $openid->identity = 'http://steamcommunity.com/openid';
            header('Location: ' . $openid->authUrl()); // LINE 17
        }
这是我的index.php文件:

<?php
require 'steamauth/steamauth.php';

if(!isset($_SESSION['steamid'])) {
    echo "welcome guest! please login \n \n";
    steamlogin(); //login button
    }  else {
    //Protected content
    echo "OMG! You logged in! :D \n";
    echo "your steam ID is: " . $_SESSION['steamid'] . "\n"; //prints their steam ID!
    logoutbutton();
}
?>

这就是我试图使用的:

如果有人能帮忙,我很乐意得到帮助。我四处搜索,尝试了不同的解决方案

即:


我还检查了一些内容,例如位于正确的位置,并且位于文件的开头/结尾。

如果在调用页面之前页面上有一些输出,则无法通过页眉传输页面

比如

echo "Yes";
header("location:something.php");
exit;
这会给你类似的警告

警告:无法修改标题信息-标题已由发送人发送(输出从xxxx第17行开始

因此,在
index.php
中检查您的行no
5
,将会有一些输出被打印出来

index.php上的第5行是

echo“欢迎来宾!请登录\n\n”


上面的内容是在index.php上打印的,然后您传输头。因此错误是commes。

我正在从WAMPserver迁移到IIS

这两天来一直在努力解决这个问题,它在生产环境中运行良好(错误报告关闭),但在本地主机上运行不好(错误报告打开)

当我关闭localhost上的错误报告时,一切都正常

当页面上出现通知错误时,您已经注定要失败,因为页眉已经被修改,因此

Warning: Cannot modify header information - headers already sent by (output started at /home/namehere/public_html/index.php:5)

此处有更多信息:

实际上,在将任何输出(空格也被视为输出)发送到浏览器之前,需要调用
header()
函数。尝试使用此函数替代
header()
函数。谢谢,我将echo放在了steamlogin()下面;它工作正常。但是,它说当我/确实登录时它没有登录,你有什么想法吗?@woopwoopwoopwoopwoopwoop,这个问题已经在这里得到了回答: