首页 > 解决方案 > 为什么脚本使用不同的虚拟主机表现不同?

问题描述

我有一个使用无限免费虚拟主机的运行良好的脚本。由于某些原因,相同的脚本无法在 Awardspace 虚拟主机上运行。两个主机都启用 php。

我得到的错误信息:

Warning: session_start(): Cannot send session cache limiter - headers already sent [...] line 2

Warning: file_get_contents(http://ipinfo.io/37.76.66.143/json): failed to open stream: Connection refused in [...] line 52

Warning: Cannot modify header information - headers already sent by [..] line 72

脚本开始像(第 1-3 行):

<?php
session_start(); 
?>

行 (51-53):

$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
$locationData = $details->city;

行 (68-75):

if($_SESSION['username'] == "admin")
{
    header('Location: adminPage.php');
}
else
{
    header('Location: landingPage.php');
}

标签: phphtmljsonweb-hosting

解决方案


推荐阅读