How can one ensure that the correct port is being used when checking the status of a Teamspeak server in PHP?

To ensure that the correct port is being used when checking the status of a Teamspeak server in PHP, you can specify the port number in the connection settings. By explicitly setting the port, you can ensure that the PHP script connects to the correct port on the Teamspeak server.

<?php

$serverIp = 'your_server_ip';
$serverPort = 'your_server_port';

// Connect to Teamspeak server
$socket = @fsockopen($serverIp, $serverPort, $errno, $errstr, 1);

if (!$socket) {
    echo "Server is offline";
} else {
    echo "Server is online";
    
    // Close the socket connection
    fclose($socket);
}

?>