I had a script in one of my websites that fetched DNS Records using dns_get_record() PHP function. But it's about 2 week that this function returns an empty array. I wrote a test script like below:
<?php
$result = dns_get_record("php.net");
if (count($result)) {
print_r($result);
} else {
echo 'Empty Array';
}
?>
It works well on my local machine, but when I test it on my server, it returns Empty Array as result.
What's the matter friends ?
Check DNS ports are open on the server, it requires TCP/UDP port 53.
You can check that your server can make outbound DNS queries by typing the following
dig exmaple.comand see if you get the expected response.Check server has DNS servers set and then check the firewall as previously suggested.
Lastly, worth check PHP versions on each machine?