我用过
if(!empty($_SERVER['HTTP_CLIENT_IP']))
{
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
$ip = $_SERVER['REMOTE_ADDR'];
}
echo $ip;
获取客户端IP地址
当我在我的本地服务器上测试时,它正在工作,但是当我将文件上传到我托管我的网络的远程服务器时,它正在获取我的服务器IP地址而不是客户端IP