📄 function.dns-get-record.html
字号:
<i>refresh</i>: Refresh interval (seconds) secondary name servers should use when updating remote copies of this domain. <i>retry</i>: Length of time (seconds) to wait after a failed refresh before making a second attempt. <i>expire</i>: Maximum length of time (seconds) a secondary DNS server should retain remote copies of the zone data without a successful refresh before discarding. <i>minimum-ttl</i>: 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. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>AAAA</i></td> <td colspan="1" rowspan="1" align="left"> <i>ipv6</i>: IPv6 address </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>A6</i>(PHP >= 5.1.0)</td> <td colspan="1" rowspan="1" align="left"> <i>masklen</i>: Length (in bits) to inherit from the target specified by <i><tt class="parameter">chain</tt></i>. <i>ipv6</i>: Address for this specific record to merge with <i><tt class="parameter">chain</tt></i>. <i>chain</i>: Parent record to merge with <i><tt class="parameter">ipv6</tt></i> data. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>SRV</i></td> <td colspan="1" rowspan="1" align="left"> <i>pri</i>: (Priority) lowest priorities should be used first. <i>weight</i>: Ranking to weight which of commonly prioritized <i><tt class="parameter">targets</tt></i> should be chosen at random. <i>target</i> and <i>port</i>: hostname and port where the requested service can be found. For additional information see: <a href="http://www.faqs.org/rfcs/rfc2782" class="link external">» RFC 2782</a> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>NAPTR</i></td> <td colspan="1" rowspan="1" align="left"> <i>order</i> and <i>pref</i>: Equivalent to <i><tt class="parameter">pri</tt></i> and <i><tt class="parameter">weight</tt></i> above. <i>flags</i>, <i>services</i>, <i>regex</i>, and <i>replacement</i>: Parameters as defined by <a href="http://www.faqs.org/rfcs/rfc2915" class="link external">» RFC 2915</a>. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Using <b>dns_get_record()</b></b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">dns_get_record</span><span style="color: #007700">(</span><span style="color: #DD0000">"php.net"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>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 ))</pre></div> </pre></div> </div> <div class="example"> <p><b>Example #2 Using <b>dns_get_record()</b> and DNS_ANY</b></p> <div class="example-contents"><p> Since it's very common to want the IP address of a mail server once the MX record has been resolved, <b>dns_get_record()</b> also returns an array in <i><tt class="parameter">addtl</tt></i> which contains associate records. <i><tt class="parameter">authns</tt></i> is returned as well containing a list of authoritative name servers. </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* Request "ANY" record for php.net,<br /> and create $authns and $addtl arrays<br /> containing list of name servers and<br /> any additional records which go with<br /> them */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">dns_get_record</span><span style="color: #007700">(</span><span style="color: #DD0000">"php.net"</span><span style="color: #007700">, </span><span style="color: #0000BB">DNS_ANY</span><span style="color: #007700">, </span><span style="color: #0000BB">$authns</span><span style="color: #007700">, </span><span style="color: #0000BB">$addtl</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Result = "</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Auth NS = "</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$authns</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Additional = "</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$addtl</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>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 ))</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: This function is not implemented on Windows platforms, nor does it (currently) work on *BSD systems (including Mac). Try the <a href="http://pear.php.net/" class="link external">» PEAR</a> class <a href="http://pear.php.net/package/Net_DNS" class="link external">» Net_DNS</a>. <br /> </p></blockquote> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.dns-get-mx.html" class="function" rel="rdfs-seeAlso">dns_get_mx()</a></li> <li class="member"><a href="function.dns-check-record.html" class="function" rel="rdfs-seeAlso">dns_check_record()</a></li> </ul> </p> </div></div><hr /><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></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -