dns_get_record
Fetch DNS Resource Records associated with a hostname.
dns_get_record Function synopsis
dns_get_record(
string $hostname,
int $type = DNS_ANY,
&$authoritative_name_servers = null,
&$additional_records = null,
bool $raw = false
): array|false
Parameters
$hostname
Typestring
$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.
$type
OptionalTypeintDefault valueDNS_ANY
By default, dns_get_record will search for any
resource records associated with $hostname.
To limit the query, use one of the
DNS_*
constants.
$authoritative_name_servers
Passed by reference, OptionalDefault valuenull
Passed by reference and, if given, will be populated with Resource Records for the Authoritative Name Servers.
$additional_records
Passed by reference, OptionalDefault valuenull
Passed by reference and, if given, will be populated with any Additional Records.
$raw
OptionalTypeboolDefault valuefalse
The $type will be interpreted as a raw DNS type ID
(the DNS_* constants cannot be used).
The return value will contain a data key, which needs
to be manually parsed.
Note that the parameters
$authoritative_name_serversand$additional_recordsare passed by reference, and contain additional/updated context data that may be useful.
Return value
Typearray|false
This function returns an array of associative arrays,
or false on failure. Each associative array contains
at minimum the following keys:
Changes to the dns_get_record Function
PHP 8.0
- Return type added:
array|false - Parameter type added for parameter #1 (
$hostname):string - Parameter type added for parameter #2 (
$type):int - Parameter default value added for position #2 (
$type):DNS_ANY - Parameter name of parameter #3 changed:
$authnsto$authoritative_name_servers - Parameter default value added for position #3 (
$authoritative_name_servers):null - Parameter name of parameter #4 changed:
$addtlto$additional_records - Parameter default value added for position #4 (
$additional_records):null - Parameter type added for parameter #5 (
$raw):bool - Parameter default value added for position #5 (
$raw):false
dns_get_record(
- $hostname,
+ string $hostname,
- $type,
+ int $type = DNS_ANY,
- array or NULL &$authns,
+ &$authoritative_name_servers = null,
- array or NULL &$addtl,
+ &$additional_records = null,
- $raw
+ bool $raw = false
- )
+ ): array|false PHP 5.4
- Optional parameter added - #5:
$raw
dns_get_record(
$hostname,
$type,
- &$authns,
- &$addtl
+ array or NULL &$authns,
+ array or NULL &$addtl,
+ $raw
) dns_get_record Function Availability
dns_get_record Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |