php - PHP Source Query 适用于本地主机但不适用于服务器
问题描述
我已使用此https://github.com/xPaw/PHP-Source-Query API 来查询网站上的 ARK 服务器信息。一切都在本地主机上完美运行,但在网络服务器上上传时却不行。PHP 在服务器上以其他方式工作,但不仅仅是这一功能。服务器上的 Apache 错误日志在页面加载时这样说:
“PHP 解析错误:语法错误,意外的 ''xPaw/SourceQuery /SourceQuery'' (T_CONSTANT_ENCAPSED_STRING),在 /var/www/jamon 中需要标识符 (T_STRING) 或函数 (T_FUNCTION) 或 const (T_CONST) 或 \\ (T_NS_SEPARATOR) /serverinfo.php 第 4 行,引用者: https ://jamonparadigm.com/servers "
Web 服务器正在运行 PHP 7。 serverinfo.php 如下所示:
<?php
require __DIR__ . '/SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
// For the sake of this example
Header( 'Content-Type: text/plain' );
Header( 'X-Content-Type-Options: nosniff' );
// The Island
define( 'SQ_SERVER_ADDR', '159.69.56.156' );
define( 'SQ_SERVER_PORT', 27000 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
$Query = new SourceQuery( );
try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
$islandInfo = $Query->GetInfo( );
$islandPlayers = $islandInfo['Players'] . "/" . $islandInfo['MaxPlayers'];
$islandVersion = trim(substr($islandInfo['HostName'], strpos($islandInfo['HostName'], '(')), "()");
$islandStatus = '<span class="text-success">online</span>';
$islandInfo2 = $Query->GetRules();
$islandDay = $islandInfo2['DayTime_s'];
}
catch( Exception $e )
{
$islandPlayers = "0/0";
$islandVersion = "";
$islandStatus = '<span class="text-danger">offline</span>';
$islandDay = "";
}
finally
{
$Query->Disconnect( );
}
?>
可以做些什么来解决这个问题?
解决方案
推荐阅读
- c# - Linq 查询返回最便宜的产品,只有它是唯一的
- python - Python - 分配错误之前引用的局部变量
- spring-boot - Redisson 的连接池统计信息
- python - 使用来自 firestore 的数据填充 WTForms 选择字段
- mongodb - 一段时间后如何在mongoDB中自动重置字段的值?
- c# - 在 Android 上的 Unity 中运行 Python 程序
- javascript - 在 PHP 中使用锚标记的 href 传递 ID 时出错?
- python-3.x - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte while access csv file
- jquery - 为什么弹出框标题函数被调用两次
- sql - 查询以排除结果