Getting location details from IP in PHP

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

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

Any suggestions ??

Thanks

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-03 15:10

     $ip = "66.96.147.144";
        $geoPlugin_array = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip) );
        echo '
    ';
        print_r($geoPlugin_array);
    
    OUTPUT :
    Array
    (
        [geoplugin_request] => 66.96.147.144
        [geoplugin_status] => 200
        [geoplugin_credit] => Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.
        [geoplugin_city] => Burlington
        [geoplugin_region] => MA
        [geoplugin_areaCode] => 781
        [geoplugin_dmaCode] => 506
        [geoplugin_countryCode] => US
        [geoplugin_countryName] => United States
        [geoplugin_continentCode] => NA
        [geoplugin_latitude] => 42.5051
        [geoplugin_longitude] => -71.204697
        [geoplugin_regionCode] => MA
        [geoplugin_regionName] => Massachusetts
        [geoplugin_currencyCode] => USD
        [geoplugin_currencySymbol] => $
        [geoplugin_currencySymbol_UTF8] => $
        [geoplugin_currencyConverter] => 1
    )
    

提交回复
热议问题