当我在一个php脚本中使用dns_get_record来获取域名的DNS记录列表时,会返回一系列记录。
但是如果我再次运行这个脚本,它并不会返回所有相同的结果(即只返回名称服务器),然后再次运行它,它就可以工作了。
以下是我使用的代码:
$result = dns_get_record("php.net");
print_r($result);
有更好的函数或更可靠的方法来查询DNS记录吗?
不起作用:
数组([0] => Array([host] => php.net [type] => NS [target] => remote2.easydns.com [class] => IN [ttl] => 38772)[1] => Array([host] => php.net [type] => NS [target] => ns1.easydns.com [class] => IN [ttl] => 38772)[2] => Array([host] => php.net [type] => NS [target] => ns2.easydns.com [class] => IN [ttl] => 38772)[3] => Array([host] => php.net [type] => NS [target] => remote1.easydns.com [class] => IN [ttl] => 38772))
正常工作:
数组([0] => Array([host] => php.net [type] => MX [pri] => 5 [target] => osu1.php.net [class] => IN [ttl] => 72984)[1] => Array([host] => php.net [type] => MX [pri] => 15 [target] => smtp.osuosl.org [class] => IN [ttl] => 72984)[2] => Array([host] => php.net [type] => NS [target] => remote2.easydns.com [class] => IN [ttl] => 30054)[3] => Array([host] => php.net [type] => NS [target] => ns1.easydns.com [class] => IN [ttl] => 30054)[4] => Array([host] => php.net [type] => NS [target] => ns2.easydns.com [class] => IN [ttl] => 30054)[5] => Array([host] => php.net [type] => NS [target] => remote1.easydns.com [class] => IN [ttl] => 30054))