How does PHP get the IP location?

Source: Internet
Author: User
How does PHP get the IP location?
I call the interface of QQ










Preg_match ("@(. *)






The output indicates that my IP can only be used inside the LAN, I am in the school, there is no API to get the address AH




Baidu a bit IP will be able to find out the address, this is how to do


------to solve the idea----------------------
I know Baidu has an API to get city http://api.map.baidu.com/location/ip?ak=xxx according to IP
To apply for AK
------to solve the idea----------------------
$url = ' http://ip.taobao.com/service/getIpInfo.php?ip= '. $Ip;
#json格式的数据
Does not pass IP, is your current public network IP data.
You pass in the intranet IP (such as 192.168***, etc.), it is certainly not recognized the HA
------to solve the idea----------------------
You can only get the IP of the extranet.
  • 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.