In fact, this is very simple, but I have always wanted to use the ipv6-test API to make something that obtains the user's IP address... Unfortunately, JSON only obtains the IP of the local server. Forget it, I won’t study it anymore, not to mention the widgets provided by others are quite easy to use. I googled it and found this code, which can obtain the IP address according to the user environment.
For example, if IPv6 accesses www.shiwo.de, the user's IPv6 address will be obtained
p.s The premise is that the website has done A and AAAA resolution
Copy code The code is as follows:
function getIP() /*Get the client IP*/
{
if (@$_SERVER["HTTP_X_FORWARDED_FOR"])
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if (@$_SERVER["HTTP_CLIENT_IP"])
$ip = $_SERVER[" HTTP_CLIENT_IP"];
else if (@$_SERVER["REMOTE_ADDR"])
$ip = $_SERVER["REMOTE_ADDR"];
else if (@getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (@getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if (@getenv("REMOTE_ADDR") )
$ip = getenv("REMOTE_ADDR");
else
$ip = "Unknown";
return $ip;
}
?>
http://www.bkjia.com/PHPjc/326295.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326295.htmlTechArticleActually, this is very simple, but I have always wanted to use the ipv6-test API to make something to obtain the user's IP address. ...Unfortunately, what JSON obtains is only the IP of the local server. Forget it, no more research,...