Retrieve DNS Resource Records - dns_get_record()
The dns_get_record() function returns an array consisting of various DNS resource records pertinent to a specific domain.
By default, dns_get_record() returns all records it can find specific to the supplied domain; however, you can streamline the retrieval process by specifying a type, the name of which must be prefaced with DNS.
Assuming that the supplied hostname is valid and exists, a call to dns_get_record() returns at least four attributes:
- host: Specifies the name of the DNS namespace to which all other attributes correspond.
- class: Returns records of class Internet only, so this attribute always reads IN.
- type: Determines the record type. Depending upon the returned type, other attributes might also be made available.
- ttl: Calculates the record’s original time-to-live minus the amount of time that has passed since the authoritative name server was queried.