What is the best way to check if a CS Server or Teamspeak Server is online using PHP?

One way to check if a CS Server or Teamspeak Server is online using PHP is to use the `fsockopen` function to establish a connection to the server's IP address and port. If the connection is successful, the server is considered online. Here is a PHP code snippet that demonstrates this:

function checkServerOnline($ip, $port) {
    $connection = @fsockopen($ip, $port, $errno, $errstr, 1);
    
    if ($connection) {
        fclose($connection);
        return true; // Server is online
    } else {
        return false; // Server is offline
    }
}

// Usage example
$csServerIp = '192.168.1.100';
$csServerPort = 27015;

if (checkServerOnline($csServerIp, $csServerPort)) {
    echo 'CS Server is online';
} else {
    echo 'CS Server is offline';
}