uTools-Manuals/docs/php/geoip_record_by_name.html
2019-04-28 19:00:34 +08:00

201 lines
6.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>返回 GeoIP 数据库中详细的城市信息</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.geoip-record-by-name" class="refentry">
<div class="refnamediv">
<h1 class="refname">geoip_record_by_name</h1>
<p class="verinfo">(PECL geoip &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">geoip_record_by_name</span> &mdash; <span class="dc-title">返回 GeoIP 数据库中详细的城市信息</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.geoip-record-by-name-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>geoip_record_by_name</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$hostname</code></span>
) : <span class="type">array</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>geoip_record_by_name()</strong></span> 函数将会返回主机或者 IP 地址所对应的记录信息。
</p>
<p class="para">
该函数在 GeoLite City 版本和商业 GeoIP City 版本中可用。 版本不对的话,将会抛出一个警告。
</p>
<p class="para">
返回的关联数组不同的键名对应如下:
</p>
<p class="para">
<ul class="itemizedlist">
<li class="listitem">
<span class="simpara">
&quot;continent_code&quot; -- 由两个字符组成的洲简称。(要求 GeoIP 的库版本是1.0.4以上)
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;country_code&quot; -- 由2个字母组成的国家简称。(参见
<span class="function"><a href="geoip_country_code_by_name.html" class="function">geoip_country_code_by_name()</a></span>)
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;country_code3&quot; -- 由三个字母组成的国家简称。(参见
<span class="function"><a href="geoip_country_code3_by_name.html" class="function">geoip_country_code3_by_name()</a></span>)
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;country_name&quot; -- 国家名称 (参见
<span class="function"><a href="geoip_country_name_by_name.html" class="function">geoip_country_name_by_name()</a></span>)
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;region&quot; -- 地区代码 (比如: CA 对应 California)
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;city&quot; -- 城市名称。
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;postal_code&quot; -- 邮编FSA 或者 Zip 编码。
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;latitude&quot; -- 有符号的双精度纬度。
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;longitude&quot; -- 有符号的双精度经度。
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;dma_code&quot; -- 指定市场区号 (只支持美国和加拿大)
</span>
</li>
<li class="listitem">
<span class="simpara">
&quot;area_code&quot; -- PSTN (公共交换电话网络)地区代码。 (比如: 212)
</span>
</li>
</ul>
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.geoip-record-by-name-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">hostname</code></dt>
<dd>
<p class="para">
所要查找的主机或者 IP 地址。
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.geoip-record-by-name-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功,返回关联数组,未找到相关信息则返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 changelog" id="refsect1-function.geoip-record-by-name-changelog">
<h3 class="title">更新日志</h3>
<p class="para">
<table class="doctable informaltable">
<thead>
<tr>
<th>版本</th>
<th>说明</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td>1.0.4</td>
<td>
给 GeoIP 1.4.4及以上版本的库添加 continent_code 字段。
</td>
</tr>
<tr>
<td>1.0.3</td>
<td>
添加 country_code3 和 country_name 字段。
</td>
</tr>
</tbody>
</table>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.geoip-record-by-name-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-4497">
<p><strong>Example #1 <span class="function"><strong>geoip_record_by_name()</strong></span> 例子:</strong></p>
<div class="example-contents"><p>
以下例程将会输出包含 example.com 主机记录的数组。
</p></div>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$record&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">geoip_record_by_name</span><span style="color: #007700">(</span><span style="color: #DD0000">'www.example.com'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$record</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$record</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程会输出:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
Array
(
[continent_code] =&gt; NA
[country_code] =&gt; US
[country_code3] =&gt; USA
[country_name] =&gt; United States
[region] =&gt; CA
[city] =&gt; Marina Del Rey
[postal_code] =&gt;
[latitude] =&gt; 33.9776992798
[longitude] =&gt; -118.435096741
[dma_code] =&gt; 803
[area_code] =&gt; 310
)
</pre></div>
</div>
</div>
</p>
</div>
</div></div></div></body></html>