Getting location details from IP in PHP

前端 未结 7 1511
傲寒
傲寒 2021-02-03 14:30

Is it possible to get the location details from the users IP Address in PHP.

Any suggestions ??

Thanks

7条回答
  •  遥遥无期
    2021-02-03 15:07

    $ip = '98.229.152.237';
    $xml = simplexml_load_file("http://ipinfodb.com/ip_query.php?ip=$ip");
    print_r($xml);
    

    Output:

    SimpleXMLElement Object
    (
        [Ip] => 98.229.152.237
        [Status] => OK
        [CountryCode] => US
        [CountryName] => United States
        [RegionCode] => 33
        [RegionName] => New Hampshire
        [City] => Manchester
        [ZipPostalCode] => 03103
        [Latitude] => 42.9403
        [Longitude] => -71.4435
        [Timezone] => -5
        [Gmtoffset] => -5
        [Dstoffset] => -4
    )
    

提交回复
热议问题