Get user country by IP in PHP – external server method

function get_user_country_by_ip( $ip ) {
	$country = file_get_contents( 'http://api.hostip.info/country.php?ip=' . $ip );
	return $country;
}

Leave a Comment