<!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>Returns the detailed City information found in the GeoIP Database</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.geoip-org-by-name.html">geoip_org_by_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.geoip-region-by-name.html">geoip_region_by_name</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-record-by-name" class="refentry"> <div class="refnamediv"> <h1 class="refname">geoip_record_by_name</h1> <p class="verinfo">(PECL geoip >= 0.2.0)</p><p class="refpurpose"><span class="refname">geoip_record_by_name</span> — <span class="dc-title">Returns the detailed City information found in the GeoIP Database</span></p> </div> <div class="refsect1 description" id="refsect1-function.geoip-record-by-name-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>geoip_record_by_name</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$hostname</code></span> )</div> <p class="para rdfs-comment"> The <span class="function"><strong>geoip_record_by_name()</strong></span> function will return the record information corresponding to a hostname or an IP address. </p> <p class="para"> This function is available for both GeoLite City Edition and commercial GeoIP City 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"> "continent_code" -- Two letter continent code (as of version 1.0.4 with libgeoip 1.4.3 or newer) </span> </li> <li class="listitem"> <span class="simpara"> "country_code" -- Two letter country code (see <span class="function"><a href="function.geoip-country-code-by-name.html" class="function">geoip_country_code_by_name()</a></span>) </span> </li> <li class="listitem"> <span class="simpara"> "country_code3" -- Three letter country code (see <span class="function"><a href="function.geoip-country-code3-by-name.html" class="function">geoip_country_code3_by_name()</a></span>) </span> </li> <li class="listitem"> <span class="simpara"> "country_name" -- The country name (see <span class="function"><a href="function.geoip-country-name-by-name.html" class="function">geoip_country_name_by_name()</a></span>) </span> </li> <li class="listitem"> <span class="simpara"> "region" -- The region code (ex: CA for California) </span> </li> <li class="listitem"> <span class="simpara"> "city" -- The city. </span> </li> <li class="listitem"> <span class="simpara"> "postal_code" -- The Postal Code, FSA or Zip Code. </span> </li> <li class="listitem"> <span class="simpara"> "latitude" -- The Latitude as signed double. </span> </li> <li class="listitem"> <span class="simpara"> "longitude" -- The Longitude as signed double. </span> </li> <li class="listitem"> <span class="simpara"> "dma_code" -- Designated Market Area code (USA and Canada only) </span> </li> <li class="listitem"> <span class="simpara"> "area_code" -- The PSTN area code (ex: 212) </span> </li> </ul> </p> </div> <div class="refsect1 parameters" id="refsect1-function.geoip-record-by-name-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">hostname</code></em></span> <dd> <p class="para"> The hostname or IP address whose record is to be looked-up. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.geoip-record-by-name-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the associative array on success, or <strong><code>FALSE</code></strong> if the address cannot be found in the database. </p> </div> <div class="refsect1 changelog" id="refsect1-function.geoip-record-by-name-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>1.0.4</td> <td> Adding the continent_code with GeoIP Library 1.4.3 or newer only </td> </tr> <tr> <td>1.0.3</td> <td> Adding country_code3 and country_name </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.geoip-record-by-name-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3741"> <p><strong>Example #1 A <span class="function"><strong>geoip_record_by_name()</strong></span> example</strong></p> <div class="example-contents"><p> This will print the array containing the record of host example.com. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$record </span><span style="color: #007700">= </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 (</span><span style="color: #0000BB">$record</span><span style="color: #007700">) {<br /> </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">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> Array ( [continent_code] => NA [country_code] => US [country_code3] => USA [country_name] => United States [region] => CA [city] => Marina Del Rey [postal_code] => [latitude] => 33.9776992798 [longitude] => -118.435096741 [dma_code] => 803 [area_code] => 310 ) </pre></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.geoip-org-by-name.html">geoip_org_by_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.geoip-region-by-name.html">geoip_region_by_name</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>