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();
}
?>
这就是我想要使用的内容:https://github.com/SmItH197/SteamAuthentication
如果有人可以提供帮助,我很乐意得到帮助。我四处搜寻并尝试了不同的解决方案。
即: PHP header not working for server but works perfectly fine on local host
我还检查了诸如位于正确位置的内容,并且它们位于文件的开头/结尾。
答案 0 :(得分:0)
如果在调用之前页面上有一些输出
,则无法通过标题传输页面,例如
echo "Yes";
header("location:something.php");
exit;
这会给你一个警告,如
Warning: Cannot modify header information - headers already sent by (output started at xxxx on line 17
因此请检查5
中的行号index.php
是否会打印一些输出。
index.php上的第5行是
echo "welcome guest! please login \n \n";
以上是在index.php上打印然后转移标题。所以错误就是注释。
答案 1 :(得分:0)
我正在从WAMPserver迁移到IIS。
两天来一直在努力解决这个问题,因为它在生产(错误报告关闭)上工作正常但在Localhost上没有(错误报告)
当我在localhost上关闭错误报告时,一切运行正常。
当页面上出现通知错误时,您已经注定已失败,因为标题已被修改,因此
Warning: Cannot modify header information - headers already sent by (output started at /home/namehere/public_html/index.php:5)
有关此内容的更多信息:https://wordpress.org/support/topic/localhost-works-fine-but-live-site-generating-header-error