我试图在PHP中创建一个工具,它只是列出输入的域的区域文件的组件。但是遇到了一个恼人的错误,对于A / AAAA / CNAME记录,它拒绝将数据打印出来作为数组的成员。
$NS = dns_get_record($url, DNS_NS);
$MX = dns_get_record($url,DNS_MX);
$A = dns_get_record($url,DNS_A);
$AAAA = dns_get_record($url,DNS_AAAA);
$CNAME = dns_get_record($url,DNS_CNAME);
$SRV = dns_get_record($url,DNS_SRV);
$A6 = dns_get_record($url,DNS_A6);
$ALL = dns_get_record($url,DNS_ALL);
$TXT = dns_get_record($url,DNS_TXT);
//Nameservers
echo "<br/><h4>$url's NS(Name Server) records are:</h4><br/>";
//echo $nameserver;
foreach ($NS as $dump) {
echo $dump['target'], "</br>";
}
// MX Servers
echo "<br/><h4>$url's MX(Mail Exchanger) records are:</h4><br/>";
foreach ($MX as $dump) {
echo $dump['target'], "</br>";
}
//A record servers
echo "<br/><h4>$url's A records are:</h4><br/>";
$fuck = var_dump($A);
foreach ($A as $dump) {
echo $dump['target'], "</br>";
}
//AAAA Record Servers
echo "<br/><h4>$url's AAAA records are:</h4><br/>";
foreach ($AAAA as $dump) {
echo $dump['target'], "</br>";
}
//CNAME Record Servers
echo "<br/><h4>$url's CNAME records are:</h4><br/>";
foreach ($CNAME as $dump) {
echo $dump['target'], "</br>";
}
//SRV Records
echo "<br/><h4>$url's SRV records are:</h4><br/>";
foreach ($SRV as $dump) {
echo $dump['target'], "</br>";
}
//A6 Records
echo "<br/><h4>$url's A6 records are:</h4><br/>";
foreach ($A6 as $dump) {
echo $dump['target'], "</br>";
}
//TXT records
echo "<br/><h4>$url's TXT records are:</h4><br/>";
foreach ($TXT as $dump) {
echo $dump['target'], "</br>";
}
以A记录为例,当我做VAR_DUMP时,它似乎显示了信息,尽管形式令人难以置信的难看。然而,显示的循环似乎什么都不做。我还注意到,在这里,信息丢失(可能是由于其他记录拒绝显示),例如我测试了我的域名和FTP。记录未能出现在这里。
$ url是从$ _POST [&#39; url&#39;]传递的,其格式为example.com,没有任何http或任何先前或后续的废话。
我怎样才能让我的循环以完美的ordaly fassion返回完整的区域文件?我误解了数组在这里是如何工作的,还是我刚刚做了一些非常基本但又愚蠢的事情?