标签:get getenv div private 获取 cli class pac iss
//获取用户真实IP private 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中getenv("REMOTE_ADDR")和$_SERVER[‘REMOTE_ADDR‘]都能获取到用户浏览器所在电脑IP,二者的区别在于getenv不能获取IIS搭建的服务器,只能获取到apache所在的服务器,而$_SERVER可以获取到全部的
标签:get getenv div private 获取 cli class pac iss
原文地址:http://www.cnblogs.com/hanshuai0921/p/6680908.html