我正在为我们的客户创建一个工具来检查他们的域名是否存在。我计划使用 gethostbyname($domain) 函数。但是,我想对其他 TLD 进行预编程,这些 TLD 将与他们首选的 TLD(通过表格发送)一起检查。我真的不知道从哪里开始,所以我在下面提供了我的示例以供用户建议。
// SUPPORTED TOP-LEVEL DOMAIN NAMES (TLDS)
$TLD['COMING_SOON'] = ".REALTY, .CONSTRUCTION";
$TLD['CURRENT'] = ".COM, .ORG, .US";
// RECEIVE FORM DATA AND STRIP TAGS
$SOURCE = $_SERVER['HTTP_REFERER'];
$DOMAIN = strip_tags($_POST['domain_name']);
$TLD = strip_tags($_POST['tld']);
$REQ = $DOMAIN.$TLD;
// CHECK CLIENT'S PREFERRED DOMAIN
if ( gethostbyname($REQ) != $REQ ) {
echo "DNS Record found";
} else {
echo "NO DNS Record found";
}
// TO DO: CHECK ALTERNATIVE TOP-LEVEL DOMAINS
// TO DO: SOMEHOW SEARCH THROUGH THE $TLD ARRAY, COMPARE, AND GIVE RESULT