php dns记录

时间:2009-09-06 16:59:58

标签: php dns

当我在php脚本中使用dns_get_record获取域的DNS记录列表时,会返回一个记录列表。

但是如果我再次运行脚本,它不会返回所有相同的结果(即它只返回名称服务器)然后如果我再次运行它就会起作用等。

这是我正在使用的代码:

$result = dns_get_record("php.net");
print_r($result);

是否有更好的使用功能或更可靠的查询DNS记录的方式?

不工作:

Array([0] => Array([host] => php.net [type] => NS [target] => remote2.easydns.com [class] => IN [ttl] => 38772)[1] =>数组([host] => php.net [type] => NS [target] => ns1.easydns.com [class] => IN [ttl] => 38772)[2] =>数组([host] => php.net [type] => NS [target] => ns2.easydns.com [class] => IN [ttl] => 38772)[3] =>数组([host] => php.net [type] => NS [target] => remote1.easydns.com [class] => IN [ttl] => 38772))

WORKING:

数组([0] =>数组([主机] => php.net [类型] => MX [pri] => 5 [目标] => osu1.php.net [等级] => IN [ttl] => 72984)[1] =>数组([host] => php.net [type] => MX [pri] => 15 [target] => smtp .osuosl.org [class] => IN [ttl] => 72984)[2] =>数组([host] => php.net [type] => NS [target] => remote2 .easydns.com [class] => IN [ttl] => 30054)[3] =>数组([host] => php.net [type] => NS [target] => ns1 .easydns.com [class] => IN [ttl] => 30054)[4] =>数组([host] => php.net [type] => NS [target] => ns2 .easydns.com [class] => IN [ttl] => 30054)[5] =>数组([host] => php.net [type] => NS [target] => remote1 .easydns.com [class] => IN [ttl] =>> 30054))

1 个答案:

答案 0 :(得分:7)

将DNS_ALL添加到函数调用应该可以正常工作

$result = dns_get_record("php.net",DNS_ALL);
print_r($result);

确保收集所有不同的记录。