dns_get_record
dns_get_record
Fetch DNS Resource Records associated with a hostname
**dns_get_record** string $hostname int $type array $authoritative_name_servers array $additional_records bool $raw
Fetch DNS Resource Records associated with the given
.
hostname
hostname
should be a valid DNS hostname such
as "". Reverse lookups can be generated
using notation, but
is more suitable for
the majority of reverse lookups.
hostname``www.example.com``in-addr.arpa``gethostbyaddr
Opmerking: > Per DNS standards, email addresses are given in format (for example: as opposed to ), be sure to check this value and modify if necessary before using it with a functions such as .
user.host``hostmaster.example.com``hostmaster@example.com``mail
type
By default, will search for any
resource records associated with .
To limit the query, use one of the
constants.
`dns_get_record``hostname``DNS_*`
authoritative_name_servers
Passed by reference and, if given, will be populated with Resource
Records for the .
Authoritative Name Servers
additional_records
Passed by reference and, if given, will be populated with any
.
Additional Records
raw
The will be interpreted as a raw DNS type ID
(the constants cannot be used).
The return value will contain a key, which needs
to be manually parsed.
type``DNS_*``data
This function returns an array of associative arrays, return.falseforfailure. Each associative array contains the following keys:
at minimum
**Voorbeeld: Using **
<?php
$result = dns_get_record("php.net");
print_r($result);
?>
Array
(
[0] => Array
(
[host] => php.net
[type] => MX
[pri] => 5
[target] => pair2.php.net
[class] => IN
[ttl] => 6765
)
[1] => Array
(
[host] => php.net
[type] => A
[ip] => 64.246.30.37
[class] => IN
[ttl] => 8125
)
)
Voorbeeld: Using and DNS_ANY
Since it's very common to want the IP address of a mail server
once the MX record has been resolved,
also returns an array in which
contains associate records.
is returned as well containing a list of authoritative name
servers.
`dns_get_record``additional_records``authoritative_name_servers`
<?php
/* Request "ANY" record for php.net,
and create $authns and $addtl arrays
containing list of name servers and
any additional records which go with
them */
$result = dns_get_record("php.net", DNS_ANY, $authns, $addtl);
echo "Result = ";
print_r($result);
echo "Auth NS = ";
print_r($authns);
echo "Additional = ";
print_r($addtl);
?>
Result = Array
(
[0] => Array
(
[host] => php.net
[type] => MX
[pri] => 5
[target] => pair2.php.net
[class] => IN
[ttl] => 6765
)
[1] => Array
(
[host] => php.net
[type] => A
[ip] => 64.246.30.37
[class] => IN
[ttl] => 8125
)
)
Auth NS = Array
(
[0] => Array
(
[host] => php.net
[type] => NS
[target] => remote1.easydns.com
[class] => IN
[ttl] => 10722
)
[1] => Array
(
[host] => php.net
[type] => NS
[target] => remote2.easydns.com
[class] => IN
[ttl] => 10722
)
[2] => Array
(
[host] => php.net
[type] => NS
[target] => ns1.easydns.com
[class] => IN
[ttl] => 10722
)
[3] => Array
(
[host] => php.net
[type] => NS
[target] => ns2.easydns.com
[class] => IN
[ttl] => 10722
)
)
Additional = Array
(
[0] => Array
(
[host] => pair2.php.net
[type] => A
[ip] => 216.92.131.5
[class] => IN
[ttl] => 6766
)
[1] => Array
(
[host] => remote1.easydns.com
[type] => A
[ip] => 64.39.29.212
[class] => IN
[ttl] => 100384
)
[2] => Array
(
[host] => remote2.easydns.com
[type] => A
[ip] => 212.100.224.80
[class] => IN
[ttl] => 81241
)
[3] => Array
(
[host] => ns1.easydns.com
[type] => A
[ip] => 216.220.40.243
[class] => IN
[ttl] => 81241
)
[4] => Array
(
[host] => ns2.easydns.com
[type] => A
[ip] => 216.220.40.244
[class] => IN
[ttl] => 81241
)
)
dns_get_mx``dns_check_record