In fact, this is very simple, but I always want to use the Ipv6-test API to do a get user IP address things ... Unfortunately, JSON gets only the IP of the native server. Forget it, do not study, not to mention that the widget is also very useful. Google a bit, find this code, you can obtain the IP address based on the user environment.
For example, IPV6 access www.shiwo.de gets the user's IPV6 address
P.S premise is that the website did a and AAAA parsing
Copy Code code as follows:
<?php
function GetIP ()/* Get 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;
}
?>