PHP dns_get_record() Function
Example
Gets the MX resource records associated with "w3.p2hp.com":
<?php
print_r(dns_get_record("w3schools.com", DNS_MX));
?>
Definition and Usage
The dns_get_record() function gets the DNS resource records associated with the specified hostname.
Syntax
dns_get_record(hostname, type, authns, addtl, raw)
Parameter Values
Parameter | Description |
---|---|
hostname | Required. Specifies a hostname (like "w3.p2hp.com") |
type | Optional. Specifies the resource record type to search for. Can be one of the following:
|
authns | Optional. Passed by reference and, if set, it will be populated with Resource Records for the Authoritative Name Servers |
addtl | Optional. Passed by reference and, if set, it will be populated with any Additional Records |
raw | Optional. A Boolean value. If set to TRUE, it queries only the requested type instead of looping type-by-type before getting the info stuff. Default is FALSE |
Technical Details
Return Value: |
An array of associative arrays, FALSE on failure. Each array contains the following keys (at minimum):
Other keys in the arrays depends on the type parameter. |
---|---|
PHP Version: | 5.0+ |
PHP Changelog: | PHP 7.0.16: Added support for DNS_CAA type. PHP 5.4: Added the raw parameter. PHP 5.3: Available on Windows platforms. |
❮ PHP Network Reference