为什么我在检查 DNS 时得到如此随机的结果?
代码如下:
$domain = "fosajfjdkgdajfhsd.com";
$check1 = checkdnsrr($domain, "MX");
$check2 = checkdnsrr($domain, "A");
$check3 = (checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
$check4 = !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
die("{$check1} - {$check2} - {$check3} - {$check4}");
但是,当我检查输出以查看它返回的内容时,我得到:
- 1 - 1 -
该域显然不会存在,所以我不明白为什么检查 A 记录返回 true 而检查 MX 结果不返回根本不给我任何东西。我不明白这里出了什么问题。
The code is as follows:
$domain = "fosajfjdkgdajfhsd.com";
$check1 = checkdnsrr($domain, "MX");
$check2 = checkdnsrr($domain, "A");
$check3 = (checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
$check4 = !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
die("{$check1} - {$check2} - {$check3} - {$check4}");
However when I check the output to see what it's returning, I get this:
- 1 - 1 -
The domain obviously wouldn't exist, so I don't understand why checking the A record is returning true and checking the MX result doesn't give me anything at all. I don't understand what's going wrong here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,浏览完 PHP.net 文档中
checkdnsrr()
的所有示例后,我发现对于 A 记录,您仍然需要附加一个“.”。到域的末尾以便检查它是否有效。我认为 PHP 会自动为你做这样的事情,但不管怎样都行。现在结果符合预期。Ok, so after browsing through all of the examples in the PHP.net documentation for
checkdnsrr()
I figured out that for A records you are still required to append a '.' to the end of the domain in order to check it validly. I figured PHP would automatically do that kind of thing for you, but whatever works. Results are as expected now.编辑:检查您的 DNS 提供商。如今,很多人都会返回自己的 A 记录,这样如果域名无法解析,他们就可以将广告放在您的眼前。破坏了 DNS,但支付了账单。
EDIT: Check your DNS provider. Nowadays, lots of them will return their own A record so they can put ads in front of you eyes if the domain can't be resolved. Breaks DNS, but pays the bills.