What are some best practices for checking the reachability of multiple servers in PHP?

When working with multiple servers in PHP, it's important to ensure that each server is reachable before attempting to establish a connection. One way to achieve this is by using the `fsockopen` function to check the reachability of each server. By iterating through a list of server addresses and attempting to open a socket connection to each one, you can determine which servers are reachable and which ones are not.

$servers = array('server1.com', 'server2.com', 'server3.com');

foreach ($servers as $server) {
    $fp = @fsockopen($server, 80, $errno, $errstr, 1);
    if ($fp) {
        echo "Server $server is reachable.\n";
        fclose($fp);
    } else {
        echo "Server $server is not reachable.\n";
    }
}