This function returns an array of associative arrays. Each associative array contains at minimum the following keys:
Таблица 1. Basic DNS attributes
Attribute | Meaning |
---|---|
host | The record in the DNS namespace to which the rest of the associated data refers. |
class | dns_get_record() only returns Internet class records and as such this parameter will always return IN. |
type | String containing the record type. Additional attributes will also be contained in the resulting array dependant on the value of type. See table below. |
ttl | Time To Live remaining for this record. This will not equal the record's original ttl, but will rather equal the original ttl minus whatever length of time has passed since the authoritative name server was queried. |
hostname should be a valid DNS hostname such as "www.example.com". Reverse lookups can be generated using in-addr.arpa notation, but gethostbyaddr() is more suitable for the majority of reverse lookups.
By default, dns_get_record() will search for any resource records associated with hostname. To limit the query, specify the optional type parameter. type may be any one of the following: DNS_A, DNS_CNAME, DNS_HINFO, DNS_MX, DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_ALL or DNS_ANY. The default is DNS_ANY.
Замечание: Because of excentricities in the performance of libresolv between platforms, DNS_ANY will not always return every record, the slower DNS_ALL will collect all records more reliably.
The optional third and fourth arguments to this function, authns and addtl are passed by reference and, if given, will be populated with Resource Records for the Authoritative Name Servers, and any Additional Records respectively. See the example below.
Таблица 2. Other keys in associative arrays dependant on 'type'
Type | Extra Columns |
---|---|
A | ip: An IPv4 addresses in dotted decimal notation. |
MX | pri: Priority of mail exchanger. Lower numbers indicate greater priority. target: FQDN of the mail exchanger. See also dns_get_mx(). |
CNAME | target: FQDN of location in DNS namespace to which the record is aliased. |
NS | target: FQDN of the name server which is authoritative for this hostname. |
PTR | target: Location within the DNS namespace to which this record points. |
TXT | txt: Arbitrary string data associated with this record. |
HINFO | cpu: IANA number designating the CPU of the machine referenced by this record. os: IANA number designating the Operating System on the machine referenced by this record. See RFC 1010 for the meaning of these values. |
SOA | mname: FQDN of the machine from which the resource records orignated. rname: Email address of the administrative contain for this domain. serial: Serial # of this revision of the requested domain. refresh: Refresh interval (seconds) secondary name servers should use when updating remote copies of this domain. retry: Length of time (seconds) to wait after a failed refresh before making a second attempt. expire: Maximum length of time (seconds) a secondary DNS server should retain remote copies of the zone data without a successful refresh before discarding. minimum-ttl: Minimum length of time (seconds) a client can continue to use a DNS resolution before it should request a new resolution from the server. Can be overridden by individual resource records. |
AAAA | ipv6: IPv6 address |
Замечание: Per DNS standards, email addresses are given in user.host format (for example: hostmaster.example.com as opposed to hostmaster@example.com), be sure to check this value and modify if necessary before using it with a functions such as mail().
Since it's very common to want the IP address of a mail server once the MX record has been resolved, dns_get_record() also returns an array in addtl which contains associate records. authns is returned as well conatining a list of authoritative name servers.
Пример 2. Using dns_get_record() and DNS_ANY
|
See also dns_get_mx(), and dns_check_record()
Пред. | Начало | След. |
dns_get_mx | Уровень выше | fsockopen |