How to perform DNS lookup on a domain name in PHP?

PHP offers a built-in function dns_get_record() to fetch DNS resource information associated with a domain name.

Syntax of dns_get_record()

The following is the syntax of dns_get_record() function.

dns_get_record ( string $hostname [, int $type = DNS_ANY [, array &$authns [, array &$addtl [, bool $raw = FALSE ]]]] ) : array

This function takes a valid DNS hostname such as www.codingpanel.com as the first argument. The remaining parameters are optional and include DNS type, Authoritative name servers, reference to any additional records, and a raw DNS type ID.

The function returns an array containing the DNS attributes on success or FALSE on failure.
Example

<pre>
<?php
$d = "www.codingpanel.com";
$result = dns_get_record($d);
print_r($result);
?>
</pre>