实际上我正在尝试立即获取域名列表的A和MX记录,
function DNSrecord() {
$domaindata=array('revilossor.com,elliscaravans.co.uk,giggletricks.co.uk,peking-takeaway.co.uk,noeljoneslodge.co.uk,melissawhiting.co.uk,electric-hybrid-bikes.com,lovelightandpeacetents.com,ianpepper.co.uk,thelongmarch.com,mollyshouse.infodarrandigaba.com,assfa.co.uk,carolsugden.co.uk,eagleeyebusinesssolution.co.uk,clairewinteringham.com,kdpollard.com,projectyellowrose.com,naturalsynergyreiki.co.uk,chelonist.com,rickgriffithsreel.com,wilsons-garage.co.uk,fnlc.org.uk,mudinmyhair.co.uk,johnoatesltd.co.uk,acsd.co.uk,bristolthaimassage.co.uk,cycle-speed.com');
//echo gethostbyname($ip);
/* $result = dns_get_record($ip);
foreach($result[0] as $res){
echo $res.'<br />';
} */
foreach ($domaindata as $ddata){
$ddata;
}
$dns = dns_get_record( $ddata, DNS_ANY );
foreach( $dns as $d ) {
// Only print A and MX records
if( $d['type'] != "A" and $d['type'] != "MX" )
continue;
// First print all fields
echo "For " . $d['host'] . ": <br />\n";
switch( $d['type'] ) {
case 'A':
// Display annoying message
echo "<b>\n" . $d['ip'] . "</b>\n is the Primary A Record for this domain. <br /><br />\n";
break;
case 'MX':
// Resolve IP address of the mail server
$mx = dns_get_record( $d['target'], DNS_A );
foreach( $mx as $server ) {
echo "The MX record for " . $d['host'] . " points to the server <b>\n" . $d['target'] . "</b>\n whose IP address is <b>\n" . $server['ip'] . "</b>. It has a priority of <b>\n" . $d['pri'] . "</b>\n. <br /><br />\n";
}
if ( $d['target'] == $ddata ) {
echo "<i>It looks like the domain is using itself as an MX Record. You will need to create additional records.</i><br /><br />\n";
} else {
echo "<i>This MX Record looks fine.</i><br /><br />\n";
}
break;
}
}
error_reporting(E_ALL);
}
野兔是代码
当我只输入单个域时,它的作品却在我批量使用时可以; t
答案 0 :(得分:0)
首先,使用explode将字符串转换为数组:
$domaindata = 'revilossor.com,elliscaravans.co.uk,giggletricks.co.uk,peking-takeaway.co.uk,noeljoneslodge.co.uk,melissawhiting.co.uk,electric-hybrid-bikes.com,lovelightandpeacetents.com,ianpepper.co.uk,thelongmarch.com,mollyshouse.infodarrandigaba.com,assfa.co.uk,carolsugden.co.uk,eagleeyebusinesssolution.co.uk,clairewinteringham.com,kdpollard.com,projectyellowrose.com,naturalsynergyreiki.co.uk,chelonist.com,rickgriffithsreel.com,wilsons-garage.co.uk,fnlc.org.uk,mudinmyhair.co.uk,johnoatesltd.co.uk,acsd.co.uk,bristolthaimassage.co.uk,cycle-speed.com';
$domaindata = explode(',', $domaindata);
由于dns_get_record不是 foreach循环,它只会给出数组中最后一项的记录。
foreach ($domaindata as $ddata)
{
$dns = dns_get_record( $ddata, DNS_ANY );
//etc...
}
为什么在 执行你的功能后启用error_reporting() ?