Is there a way to determine whether a user has set its locale to Switzerland? I tried
$_SERVER['HTTP_ACCEPT_LANGUAGE']
but this is only giving me "de" as locale. Is there another way or maybe I did something wrong? Is there a free service for IP checks maybe?
答案 0 :(得分:0)
您可以使用this php类来获取用户在php中的位置。
获得文件后,您可以使用以下代码:
<?php
/*
* Website http://www.codehelper.io
* Author: khoaofgod@yahoo.com
* Any bugs, question, please visit our forum at http://www.codehelper.io
*/
// Required Libraries
require_once("ip.codehelper.io.php");
require_once("php_fast_cache.php");
// New Class
$_ip = new ip_codehelper();
// Detect Real IP Address & Location
$real_client_ip_address = $_ip->getRealIP();
$visitor_location = $_ip->getLocation($real_client_ip_address);
// Output result
echo $visitor_location['Country']."<br>";
echo "<pre>";
print_r($visitor_location);