douxi2670 2018-11-23 19:22
浏览 52

PHP源查询适用于localhost,但不适用于服务器

I have used this https://github.com/xPaw/PHP-Source-Query API for querying ARK server information on a website. Everything works perfectly on localhost, but not when uploaded on the web server. PHP works otherwise on the server, but not just this one feature. The Apache error log on server says this when the page is loaded:

"PHP Parse error:  syntax error, unexpected ''xPaw/SourceQuery
/SourceQuery'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier 
(T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\\\ 
(T_NS_SEPARATOR) in /var/www/jamon/serverinfo.php on line 4, referer: 
https://jamonparadigm.com/servers"

The web server is running PHP 7. The serverinfo.php looks like this:

<?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( );
}
?>

What could be done to fix the issue?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制