PHP code example of mops1k / minecraftserverstatus
1. Go to this page and download the library: Download mops1k/minecraftserverstatus library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mops1k / minecraftserverstatus example snippets
use MinecraftServerStatus\MinecraftServerStatus;
etHost('localhost')
->setPort(25565)
;
if (!$status->query()) {
echo "The Server is offline!";
} else {
$data = $status->getData();
if ($data->getFavicon()) {
echo "<img width=\"64\" height=\"64\" src=\"" . $data->getFavicon() . "\" /> <br>";
}
echo "The Server " . $data->getHostname() . " is running on " . $data->getVersion() . " and is online,
currently are " . $data->getPlayers() . " players online
of a maximum of " . $data->getMaxPlayers() . ". The motd of the server is '" . $data->getDescription() . "'.
The server has a ping of " . $data->getPing() . " milliseconds.";
}