📄 function.geoip-region-by-name.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Get the country code and region</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="ref.geoip.html">GeoIP Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.json.html">JSON</a></div> <div class="up"><a href="ref.geoip.html">GeoIP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.geoip-region-by-name" class="refentry"> <div class="refnamediv"> <h1 class="refname">geoip_region_by_name</h1> <p class="verinfo">(PECL geoip:0.2.0-1.0.1)</p><p class="refpurpose"><span class="refname">geoip_region_by_name</span> — <span class="dc-title">Get the country code and region</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>geoip_region_by_name</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$hostname</tt></span> )</div> <p class="para rdfs-comment"> The <b>geoip_region_by_name()</b> function will return the country and region corresponding to a hostname or an IP address. </p> <p class="para"> This function is currently only available to users who have bought a commercial GeoIP Region Edition. A warning will be issued if the proper database cannot be located. </p> <p class="para"> The names of the different keys of the returning associative array are as follows: </p> <p class="para"> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> "country_code" -- Two letter country code (see <a href="function.geoip-country-code-by-name.html" class="function">geoip_country_code_by_name()</a>) </span> </li> <li class="listitem"> <span class="simpara"> "region" -- The region code (ex: CA for California) </span> </li> </ul> </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"> The hostname or IP address whose region is to be looked-up. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the associative array on success, or <b><tt>FALSE</tt></b> if the address cannot be found in the database. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>geoip_region_by_name()</b> example</b></p> <div class="example-contents"><p> This will print the array containing the country code and region of the host example.com. </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$region </span><span style="color: #007700">= </span><span style="color: #0000BB">geoip_region_by_name</span><span style="color: #007700">(</span><span style="color: #DD0000">'www.example.com'</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$region</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$region</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>Array( [country_code] => US [region] => CA)</pre></div> </pre></div> </div> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.geoip.html">GeoIP Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.json.html">JSON</a></div> <div class="up"><a href="ref.geoip.html">GeoIP 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 + -