How can PHP be used to connect to a Whois service for domain verification?
To connect to a Whois service for domain verification using PHP, you can use the `fsockopen` function to establish a connection to the Whois server, send a query for the domain information, and then read the response from the server. You can parse the response to extract the relevant domain information for verification.
$domain = 'example.com';
$whois_server = 'whois.verisign-grs.com';
$port = 43;
$socket = fsockopen($whois_server, $port);
if ($socket) {
fwrite($socket, $domain . "\r\n");
$response = '';
while (!feof($socket)) {
$response .= fgets($socket, 128);
}
fclose($socket);
// Parse $response to extract domain information for verification
echo $response;
} else {
echo 'Unable to connect to Whois server';
}