男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

dns_get_record

(PHP 5, PHP 7, PHP 8)

dns_get_record獲取指定主機的DNS記錄

說(shuō)明

dns_get_record(
    string $hostname,
    int $type = DNS_ANY,
    array &$authns = ?,
    array &$addtl = ?,
    bool &$raw = false
): array

獲取指定主機(hostname)的DNS記錄。

參數

hostname

主機名(hostname)應該是一個(gè)DNS解析生效的域名,例如“www.example.com”。主機名也可以是通過(guò)對逆向解析域做DNS逆向域名解析而得到,但是在大多數情況下gethostbyaddr()更加適合做逆向域名解析。

注意:

每個(gè)DNS標準,郵件地址必須是user.host這樣的格式(例如hostmaster.example.com而不是hostmaster@example.com),在使用mail()這個(gè)函數之前請檢查這個(gè)值,有必要的話(huà)還需要修改。

type

默認情況下,dns_get_record()將會(huì )搜索所有與hostname相關(guān)的記錄,可以通過(guò)設置type來(lái)限定查詢(xún)。type的值可以是下面的其中的任何一個(gè): DNS_A,DNS_CNAME,DNS_HINFO,DNS_MX,DNS_NS,DNS_PTR,DNS_SOA,DNS_TXT,DNS_AAAA,DNS_SRV,DNS_NAPTR,DNS_A6,DNS_ALL或者DNS_ANY。

注意:

由于dns在各個(gè)平臺上表現有些不一樣,DNS_ANY不會(huì )總是返回所有的記錄,DNS_ALL雖然慢一些,但是會(huì )得到所有的記錄,所以使用DNS_ALL更加可靠些。

authns

以引用方式傳遞,如果寫(xiě)了該參數,那么將會(huì )得到該解析記錄的DNS服務(wù)器(Authoritative Name Servers)的信息。

addtl

以引用方式傳遞,如果填寫(xiě)了該參數,將會(huì )得到其他所有的DNS解析記錄。

raw

在原生模式下,在進(jìn)行額外的查詢(xún)的時(shí)候之前我們只執行請求的DNS類(lèi)型,而不是循環(huán)查詢(xún)所有的類(lèi)型。

返回值

這個(gè)函數返回一個(gè)關(guān)聯(lián)數組,如果失敗則 或者在失敗時(shí)返回 false。每個(gè)關(guān)聯(lián)數組都至少包含了以下的這些鍵。 at minimum the following keys:

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.

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 IANA's Operating System Names for the meaning of these values.
SOA mname: FQDN of the machine from which the resource records originated. 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
A6(PHP >= 5.1.0) masklen: Length (in bits) to inherit from the target specified by chain. ipv6: Address for this specific record to merge with chain. chain: Parent record to merge with ipv6 data.
SRV pri: (Priority) lowest priorities should be used first. weight: Ranking to weight which of commonly prioritized targets should be chosen at random. target and port: hostname and port where the requested service can be found. For additional information see: ? RFC 2782
NAPTR order and pref: Equivalent to pri and weight above. flags, services, regex, and replacement: Parameters as defined by ? RFC 2915.

更新日志

版本 說(shuō)明
5.4.0 增加了參數raw。
5.3.0 可以是在windows平臺上使用這個(gè)函數了。
5.3.0 在此版本之前,如果給參數authns傳入值,則必須同時(shí)傳入addtl的值。

范例

示例 #1 使用 dns_get_record()函數

<?php
$result 
dns_get_record("php.net");
print_r($result);
?>

以上例程的輸出類(lèi)似于:

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
        )

)

示例 #2 使用dns_get_record()配合DNS_ANY的例子

由于我們經(jīng)常會(huì )想獲取一個(gè)郵件服務(wù)器的對應的IP地址的MX記錄是否已經(jīng)生效。在使用dns_get_record()函數之后,addtl能夠返回一個(gè)相關(guān)的數組記錄,authns參數則會(huì )返回授權服務(wù)器的列表信息。

<?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);
?>

以上例程的輸出類(lèi)似于:

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
        )

)

注釋

注意:

For compatibility with versions before PHP 5.3.0 on some operating systems, try the ? PEAR class ? Net_DNS.

參見(jiàn)

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站