PHP gets all the information (address, ZIP code, country, latitude, longitude, etc.) of the specified (guest) IP, all information latitude and longitude
This example describes how PHP obtains all the information (address, postal code, country, latitude, longitude, etc.) of the specified (guest) IP. Share to everyone for your reference. Specific as follows:
Calling the method is straightforward. This also requires a database to support. The Chinese and pinyin coexistence in the database is only possible.
Nonsense not much to say, look at the code:
<?php function Getipinfo ($ip, $timeout =15) { if (!function_exists (' curl_init ') or!function_exists (' Simplexml_load_string ')) return false; $ch = Curl_init ("http://ipinfodb.com/ip_query2.php?ip={$ip}&timezone=true"); $options = Array ( Curlopt_returntransfer = true, ); Curl_setopt_array ($ch, $options); $res = curl_exec ($ch); Curl_close ($ch); if ($xml = simplexml_load_string ($res)) { $return = array (); foreach ($xml->location->children () as $key = = $item) { $return [$key] = Strtolower ($item); } return $return; } else { return false; } } $current _ip_info = getipinfo (' 119.7.8.255 ');
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1027492.html www.bkjia.com true http://www.bkjia.com/PHPjc/1027492.html techarticle PHP gets all the information (address, postal code, country, latitude, longitude, etc.) of the specified (guest) IP, all information latitude and longitude This example describes PHP get the specified (guest) IP all information ( ...