Simplest way goes like this:
include( 'FOnlineServer.php' );
$server = new FOnlineServer();
$server->Setup( "FOnline Server Name", "fonline.example.com", 4000 );
$server->Ping();
...php does its work...
if( $server->Status == FOnlineServer::ONLINE )
{
echo $server->Name . ' is online, players: ' . $server->Players . ', uptime: ' . $server->Uptime;
}
else
{
echo $server->Name . ' is dead or dying';
}
You can easily assume that if $server->Players is less than 0, then server is offline; be also warned, that timeout for connecting and reading data is set to very minimal values (5s for both), so you may want to increase it. Here example with 15s for connection and 30s for receiving data.
$server->Ping( 15, 30 );