I am trying to make an application that checks if the domains are registered, for this I use dns_get_record ()
, but in some domains it gives me the following error:
dns_get_record (): DNS Query failed
try {
$dominio = 'luna.info';
$dnsArr = dns_get_record($dominio . '.', DNS_NS);
} catch (Exception $e) {
if ($e->getMessage() !== 'dns_get_record(): A temporary server error occurred.') {
throw $e;
}
$dns = false;
}
if (count($dnsArr) > 0)
return false;
return true;
/* PHP version 7.1.17 - suppress error and check to insure if a non empty array is returned */
$dnsArr = @dns_get_record($dominio . '.', DNS_NS); // @ suppress errors
// check for empty array (count == 1 is empty array)
if (count($dnsArr) > 1){
// process when results present
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.