PHP Function DNS_Get_Record
php function dns_get_record is a useful tool for obtaining various types of DNS record information. It allows you to fetch information about DNS Resource Records associated with a hostname and it can be used in place of the popular dig command.
The dns_get_record() function returns an array of records matching the requested type of query. This array can contain several different key-value pairs that will vary depending on the record type specified. For example, if the record type is DNS_A, the keys will include a string of the hostname, the name server where the domain was found and the IP address. Similarly, if the record is DNS_CNAME, the keys will include the target of the aliased domain.
Other record keys that can be returned by this function are ttl – time to live remaining for the record, pri – priority of mail exchanger (lower numbers indicate greater priority), and an array of Authority Name Servers. The list of authority name servers will be sorted according to their weighted IP addresses. The array of records can also return other data such as ipv6 addresses, cpu and os data.
dns_get_record() is an inbuilt function in PHP which retrieves various types of DNS record for a hostname. It accepts a hostname and a type of record to search for, with the default being DNS_ANY. It also accepts a raw parameter that when set to true, instead of looping type-by-type it queries only the requested record before returning the info stuff.