后端开发|php教程
PHP获取IP地址,PHP获取用户访问I
后端开发-php教程
jsp 评分系统源码,ubuntu安装gmp库,tomcat长时间不请求,淘宝 爬虫 cna,php呼吸科,怎么学seo基础知识关键词lzw
本文实例为大家分享了5种PHP获取用户访问IP地址的方法,供大家参考,具体内容如下
android浏览器源码下载,ubuntu设组长,手动部署服务到tomcat,爬虫异步处理,php自学多久可以找工作,延平区专业seo服务费lzw
<?php //方法1:$ip = $_SERVER["REMOTE_ADDR"];echo $ip; //方法2:$user_IP = ($_SERVER["HTTP_VIA"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];$user_IP = ($user_IP) ? $user_IP : $_SERVER["REMOTE_ADDR"];echo $user_IP; //方法3:function getRealIp(){ $ip=false; if(!empty($_SERVER["HTTP_CLIENT_IP"])){ $ip = $_SERVER["HTTP_CLIENT_IP"]; } if (!empty($_SERVER[HTTP_X_FORWARDED_FOR])) { $ips = explode (", ", $_SERVER[HTTP_X_FORWARDED_FOR]); if ($ip) { array_unshift($ips, $ip); $ip = FALSE; } for ($i = 0; $i < count($ips); $i++) {if (!eregi ("^(10│172.16│192.168).", $ips[$i])) { $ip = $ips[$i]; break;} } } return ($ip ? $ip : $_SERVER[REMOTE_ADDR]);}echo getRealIp(); //方法4:if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]){ $ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];}elseif ($HTTP_SERVER_VARS["HTTP_CLIENT_IP"]){ $ip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];}elseif ($HTTP_SERVER_VARS["REMOTE_ADDR"]){ $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];}elseif (getenv("HTTP_X_FORWARDED_FOR")){ $ip = getenv("HTTP_X_FORWARDED_FOR");}elseif (getenv("HTTP_CLIENT_IP")){ $ip = getenv("HTTP_CLIENT_IP");}elseif (getenv("REMOTE_ADDR")){ $ip = getenv("REMOTE_ADDR");}else{ $ip = "Unknown";}echo $ip ; //方法5:if(getenv(HTTP_CLIENT_IP)) { $onlineip = getenv(HTTP_CLIENT_IP);} elseif(getenv(HTTP_X_FORWARDED_FOR)) { $onlineip = getenv(HTTP_X_FORWARDED_FOR);} elseif(getenv(REMOTE_ADDR)) { $onlineip = getenv(REMOTE_ADDR);} else { $onlineip = $HTTP_SERVER_VARS[REMOTE_ADDR];}echo $onlineip;
在线答题竞赛 源码,ubuntu更改读写权限,tomcat升级后需要重启吗,谷歌字典 爬虫,php运行网页数字代码,湛江校园seolzw