Last updated on May 20th, 2016 at 03:50 pm

Get DNS Record using PHP

. We are using dns_get_record() and displaying it using foreach statement. This is a simple tutorial which will show you how to get the DNS information / lookup of a website using php.

<?php
$result = dns_get_record("mistonline.in", DNS_ANY);
echo "Result = ";
print_r($result);
?>
<hr />
<?php
foreach($result as $y) // iterate array elements
{
if(is_array($y)) // check if $y is array
{
foreach($y as $k) // iterate array elements in $y (multidimensional)
{
echo $k."<br>"; // output the result
}
}
}?>

DEMO

2 thoughts on “Get DNS Record using PHP”
  1. I am getting Segmentation Faults if the domain contains TXT information. Know about this problem?

Leave a Reply

Your email address will not be published. Required fields are marked *