有没有办法确定用户是否已将其区域设置为瑞士?我试过
$_SERVER['HTTP_ACCEPT_LANGUAGE']
但这只是给了我"de"作为区域设置。还有别的办法吗?或者我做错了什么?可能有免费的IP检查服务吗?
您可以使用这个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);