网站地图    收藏   

主页 > 后端 > php资料库 >

php获取客户端ip get_client_ip()使用教程_自学php网

来源:自学PHP网    时间:2014-12-04 22:12 作者: 阅读:

[导读] function get_client_ip(){ if (getenv(HTTP_CLIENT_IP) strcasecmp(getenv(HTTP_CLIENT_IP), unknown)){ $ip = getenv(HTTP_CLIENT_IP); }else if (getenv(HTTP_X_FORWARDED_FOR) strcasecmp(getenv(HTTP_X_FORWARDED_FOR), unknown)){ $ip = getenv(HTTP_X_F...

function get_client_ip(){
if (getenv(“HTTP_CLIENT_IP”) && strcasecmp(getenv(“HTTP_CLIENT_IP”), “unknown”)){
$ip = getenv(“HTTP_CLIENT_IP”);
}else if (getenv(“HTTP_X_FORWARDED_FOR”) && strcasecmp(getenv(“HTTP_X_FORWARDED_FOR”), “unknown”)){
$ip = getenv(“HTTP_X_FORWARDED_FOR”);
}else if (getenv(“REMOTE_ADDR”) && strcasecmp(getenv(“REMOTE_ADDR”), “unknown”)){
$ip = getenv(“REMOTE_ADDR”);
}else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], “unknown”)){
$ip = $_SERVER['REMOTE_ADDR'];
}else{
$ip = “unknown”;

}
return($ip);
}
 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论