我从这里下载了代码:https://github.com/FunnyItsElmo/PHP-Minecraft-Server-Status-Query
我想用下面的代码回显服务器的MOTD:
<?php
include_once 'get.php'; //include the class
$status = new MinecraftServerStatus(); // call the class
$response = $status->getStatus('localhost'); // call the function
$statusTxt = "offline";
$version ="N/A";
$ping ="N/A";
$players = "0/0";
$host = "N/A";
$motd = "N/A";
$version= "N/A";
if($response){
$statusTxt="online";
$players = $response['players'] . "/" . $response['maxplayers'];
$version = $response['version'];
$ping = $response['ping'];
$host = $response['hostname'];
$motd = $response['motd'];
$version = $response['version'];
}
?>
<div id="banner">
<div id="status"><?php
echo$statusTxt;
?></div>
<div id="version"><?php
echo$version;
?></div>
<div id="ping"><?php
echo$ping;
?></div>
<div id="players"><?php
echo$players;
?></div>
<div id="host"><?php
echo $host;
?></div>
<div id="motd"><?php
echo $motd; echo $version;
?></div>
</div>但这会得到回报:
online
103
3/100
localhost
1.7.5如何回显服务器的MOTD?
发布于 2015-06-10 08:14:30
我建议使用Auto Bukkit代替,它是非常简单的我的世界服务器和MOTD的工作100%的时间。
https://stackoverflow.com/questions/23212911
复制相似问题