PHP Curl Gets the API code that specifies all the IP information

Source: Internet
Author: User
Tags curl upload file php example
This article introduces, using the Curl function in PHP to obtain the specified IP address all the information under the API code, the need for a friend reference.

Share the API code that uses curl to get all the information under the specified IP. For curl related content, you can refer to the following articles: A simple example of php curl upload file Php Curl post Simple example PHP Curl application Example Analysis PHP Example code for Curl usage PHP uses curl to determine if a remote file exists code PHP uses curl to forge an IP source code for PHP Curl Learning summary charge First, then look at the code below. The code is as follows:

     True,);    Curl_setopt_array ($ch, $options);    $res = curl_exec ($ch);    Curl_close ($ch);        if ($xml = simplexml_load_string ($res)) {$dt = array ();        foreach ($xml->location->children () as $key = = $item) {$dt [$key] = Strtolower ($item);    } return $DT;    } else {return false;  }} $current _ip_info = Getipinfo (' 61.164.140.55 '); Var_dump ($current _ip_info); /* Return content: array {["Ip"]=> string (] "61.164.140.55" ["Status"]=> string (2) "OK" ["CountryCode"]=> string (2) "CN" ["CountryName"]=> string (5) "China" ["Regioncode"]=> string (2) "" ["Regionname"]=> string (8) "En Ejiang "[" City "]=> string (5)" Ruian "[" Zippostalcode "]=> string (0)" "[" Latitude "]=> string (7)" 27.7814 "[ "Longitude"]=> string (7) "120.628" ["timeZoneName"]=> string () "Asia/chongqing" ["Gmtoffset"]=> string (5) "28800" ["Isdst"]=> string (1) "0"}*/?>
  • Related Article

    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.