php - 为什么脚本使用不同的虚拟主机表现不同?
问题描述
我有一个使用无限免费虚拟主机的运行良好的脚本。由于某些原因,相同的脚本无法在 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');
}
解决方案
推荐阅读
- c# - 创建线性二维数组的子数组
- reactjs - onChange 事件不会在日期选择时触发
- node.js - Puppeteer 下拉菜单不是选择类型
- css - Angular 8 防止文本字段标签换行符移动输入字段
- python - 从 talend 输入到 tsystem python 脚本
- go - 每次使用后都不会释放 Mysql 连接池;如何在 Golang 中正确释放连接?
- javascript - 如何将内容更改注册到受控输入字段?
- flutter - 在 moor BlobColumn 中存储双打列表
- javascript - 当您编辑表单 Devextreme 时,表单中 dxAutoComplete 中的 City 值需要一些时间才能出现
- cgal - 单精度后的自相交