📄 function.dns-get-record.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Fetch DNS Resource Records associated with a hostname</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dns-get-mx.html">dns_get_mx</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.fsockopen.html">fsockopen</a></div> <div class="up"><a href="ref.network.html">Network Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.dns-get-record" class="refentry"> <div class="refnamediv"> <h1 class="refname">dns_get_record</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">dns_get_record</span> — <span class="dc-title">Fetch DNS Resource Records associated with a hostname</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>dns_get_record</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$hostname</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$type</tt></span> ] )</div> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>dns_get_record</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$hostname</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$type</tt></span> , <span class="methodparam"><span class="type">array</span> <tt class="parameter reference">&$authns</tt></span> , <span class="methodparam"><span class="type">array</span> <tt class="parameter reference">&$addtl</tt></span> )</div> <p class="para rdfs-comment"> Fetch DNS Resource Records associated with the given <i><tt class="parameter">hostname</tt></i>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">hostname</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">hostname</tt></i> should be a valid DNS hostname such as "www.example.com". Reverse lookups can be generated using in-addr.arpa notation, but <a href="function.gethostbyaddr.html" class="function">gethostbyaddr()</a> is more suitable for the majority of reverse lookups. </p> <blockquote><p><b class="note">Note</b>: 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 <a href="function.mail.html" class="function">mail()</a>. <br /> </p></blockquote> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">type</tt></i></span> <dd> <p class="para"> By default, <b>dns_get_record()</b> will search for any resource records associated with <i><tt class="parameter">hostname</tt></i>. To limit the query, specify the optional <i><tt class="parameter">type</tt></i> parameter. May be any one of the following: <b><tt>DNS_A</tt></b>, <b><tt>DNS_CNAME</tt></b>, <b><tt>DNS_HINFO</tt></b>, <b><tt>DNS_MX</tt></b>, <b><tt>DNS_NS</tt></b>, <b><tt>DNS_PTR</tt></b>, <b><tt>DNS_SOA</tt></b>, <b><tt>DNS_TXT</tt></b>, <b><tt>DNS_AAAA</tt></b>, <b><tt>DNS_SRV</tt></b>, <b><tt>DNS_NAPTR</tt></b>, <b><tt>DNS_A6</tt></b>, <b><tt>DNS_ALL</tt></b> or <b><tt>DNS_ANY</tt></b>. The default is <em class="emphasis">DNS_ANY</em>. </p> <blockquote><p><b class="note">Note</b>: Because of eccentricities in the performance of libresolv between platforms, <b><tt>DNS_ANY</tt></b> will not always return every record, the slower <b><tt>DNS_ALL</tt></b> will collect all records more reliably. <br /> </p></blockquote> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">authns</tt></i></span> <dd> <p class="para"> Passed by reference and, if given, will be populated with Resource Records for the <em class="emphasis">Authoritative Name Servers</em>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">addtl</tt></i></span> <dd> <p class="para"> Passed by reference and, if given, will be populated with any <em class="emphasis">Additional Records</em>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> This function returns an array of associative arrays. Each associative array contains <em class="emphasis">at minimum</em> the following keys: <table border="5"> <caption><b>Basic DNS attributes</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Attribute</th> <th colspan="1">Meaning</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">host</td> <td colspan="1" rowspan="1" align="left"> The record in the DNS namespace to which the rest of the associated data refers. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">class</td> <td colspan="1" rowspan="1" align="left"> <b>dns_get_record()</b> only returns Internet class records and as such this parameter will always return <i>IN</i>. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">type</td> <td colspan="1" rowspan="1" align="left"> String containing the record type. Additional attributes will also be contained in the resulting array dependant on the value of type. See table below. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">ttl</td> <td colspan="1" rowspan="1" align="left"> Time To Live remaining for this record. This will <em class="emphasis">not</em> 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. </td> </tr> </tbody> </colgroup> </table> </p> <p class="para"> <table border="5"> <caption><b>Other keys in associative arrays dependant on 'type'</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Type</th> <th colspan="1">Extra Columns</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>A</i></td> <td colspan="1" rowspan="1" align="left"> <i>ip</i>: An IPv4 addresses in dotted decimal notation. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>MX</i></td> <td colspan="1" rowspan="1" align="left"> <i>pri</i>: Priority of mail exchanger. Lower numbers indicate greater priority. <i>target</i>: FQDN of the mail exchanger. See also <a href="function.dns-get-mx.html" class="function">dns_get_mx()</a>. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>CNAME</i></td> <td colspan="1" rowspan="1" align="left"> <i>target</i>: FQDN of location in DNS namespace to which the record is aliased. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>NS</i></td> <td colspan="1" rowspan="1" align="left"> <i>target</i>: FQDN of the name server which is authoritative for this hostname. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>PTR</i></td> <td colspan="1" rowspan="1" align="left"> <i>target</i>: Location within the DNS namespace to which this record points. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>TXT</i></td> <td colspan="1" rowspan="1" align="left"> <i>txt</i>: Arbitrary string data associated with this record. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>HINFO</i></td> <td colspan="1" rowspan="1" align="left"> <i>cpu</i>: IANA number designating the CPU of the machine referenced by this record. <i>os</i>: IANA number designating the Operating System on the machine referenced by this record. See IANA's <a href="http://www.iana.org/assignments/operating-system-names" class="link external">» Operating System Names</a> for the meaning of these values. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>SOA</i></td> <td colspan="1" rowspan="1" align="left"> <i>mname</i>: FQDN of the machine from which the resource records originated. <i>rname</i>: Email address of the administrative contain for this domain. <i>serial</i>: Serial # of this revision of the requested domain.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -