PHP gets all the information (address, ZIP code, country, latitude, longitude, etc.) of the specified (guest) IP, all information latitude and longitude _php tutorial

Source: Internet
Author: User

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 ( ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.