Why am I getting such random results when checking DNS?
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.
$ dig fosajfjdkgdajfhsd.com
; <<>> DiG 9.6.0-APPLE-P2 <<>> fosajfjdkgdajfhsd.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39121
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;fosajfjdkgdajfhsd.com. IN A
;; ANSWER SECTION:
fosajfjdkgdajfhsd.com. 0 IN A 208.69.32.132
;; Query time: 121 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Wed Apr 7 00:59:59 2010
;; MSG SIZE rcvd: 55
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.
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.
精彩评论