【发布时间】:2014-08-20 00:53:36
【问题描述】:
我想在 php 中返回域的名称服务器,但是我只将一个名称服务器放入数组中。
这是我正在使用的代码:
//get auth ns datat
$authnsData = dns_get_record($domain, DNS_NS);
//put the results into a nice array
foreach ($authnsData as $nsinfo)
{
$authns = array(
'nsdata' => array(
'nameserver' => $nsinfo['target'],
'ip' => $this->getnsIP($nsinfo['target']),
'location' => $this->getipLocation($this->getnsIP($nsinfo['target'])),
),
);
return $authns;
}
我得到的结果是:
Array
(
[nsdata] => Array
(
[nameserver] => ns-us.1and1-dns.org
[ip] => 217.160.83.2
[location] =>
)
)
假设一个域有 2 个或更多名称服务器,我只将其中一个添加到数组中。
如果您想测试它以找出问题,代码在此文件中:https://github.com/Whoisdoma/core/blob/master/src/Whoisdoma/Controllers/DNSWhoisController.php#L38
函数是getAuthNS,和LookupAuthNS。在有人建议使用 for 循环之前,我已经尝试了 for ($num = 0;) 类型的循环。
【问题讨论】: