PHP Source Query可在localhost上运行,但不能在服务器上运行

时间:2018-11-23 19:22:51

标签: php steam

我已经使用此https://github.com/xPaw/PHP-Source-Query API来查询网站上的ARK服务器信息。一切都可以在localhost上完美运行,但是在Web服务器上上传时则不能。 PHP可以在服务器上以其他方式工作,但不仅限于此功能。页面加载时,Apache错误登录服务器会显示以下信息:

"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"

Web服务器正在运行PHP7。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( );
}
?>

该如何解决此问题?

0 个答案:

没有答案