您的代码仅在出现“自定义”一词时才有效,因为您添加了这样做的条件!
$domain = $_POST['domain'];
if ($domain === 'custom') {
$domain = $_POST['customDomain'];
}
if ($domain === 'custom') {
$dnsRecords = dns_get_record($domain, DNS_NS);
// rest of the code
}
鉴于此,当用户选择自定义域时,您期望收到字符串
'custom'
。
您可以删除条件或将“自定义”一词添加到获取的正文中
'domain=custom_' + encodeURIComponent(domain)
每个域,代码将按预期工作