Php 将变量从URL抓取到MC查询中
这就是我到目前为止所做的,但由于某种原因,它不起作用Php 将变量从URL抓取到MC查询中,php,minecraft,Php,Minecraft,这就是我到目前为止所做的,但由于某种原因,它不起作用 <?PHP require MCQuery . '/MinecraftQuery.class.php'; try { $Query->Connect( '$_GET['ip'];', $_GET['port'] ); } catch( MinecraftQueryException $e ) { echo $e->getMessage
<?PHP
require MCQuery . '/MinecraftQuery.class.php';
try
{
$Query->Connect( '$_GET['ip'];', $_GET['port'] );
}
catch( MinecraftQueryException $e )
{
echo $e->getMessage( );
}
if(($Players = $Query->GetPlayers()) !== false) {
foreach($Players as $Player) {
echo "<a href='#' class='hint--bottom' data-hint=".$Player." ><img src=https://minotar.net/avatar/".$Player."/50.png Title=".$Player."></a>
";
}
}
?>
提前感谢:)这怎么样,您的代码中有语法错误
$Query->Connect( $_GET['ip'], $_GET['port'] );
而不是
$Query->Connect( '$_GET['ip'];', $_GET['port'] );
这是我自己对我的Minecraft服务器的查询。它在我的服务器上工作,我在同一个目录下有MinecraftQuery.class.php,所以一定要从那里运行它
<?php
require __DIR__ . '/MinecraftQuery.class.php';
$Query = new MinecraftQuery( );
try
{
$Query->Connect( '192.99.0.12', 25565 );
foreach ($Query->GetPlayers() as $arrayItem)
{
echo "<a href='statistics/index.php?page=player&name=" . $arrayItem . "'><img class='tooltip' style='border-radius:5;padding-top:2px'title='" . $arrayItem . "' src='https://minotar.net/avatar/" . $arrayItem ."/40'></a> " ;
}
}
catch( MinecraftQueryException $e )
{
echo $e->getMessage( );
}
?>
您应该获得一个IDE来帮助您发现像这样的简单语法错误。您发现了任何错误吗?为什么不能检查apache错误日志?[19-Apr-2014 22:00:44 Europe/Moscow]PHP解析错误:语法错误,第269行/home/caninecr/public\u html/mcquery.PHP中出现意外的“ip”(T_字符串)