2016-03-14 43 views

回答

1

您可以通過使用geoplugin第三方網站使用PHP獲取用戶的當前位置:

$userIp = getenv('REMOTE_ADDR'); 
$geoPlugin = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$userIp")); 
$user_country = $geoPlugin["geoplugin_countryName"]; 
$user_city = $geoPlugin["geoplugin_city"]; 
相關問題