PHP obtains the client IP address. Obtain the client ip address functionget_client_ip () {static $ ipNULL; if ($ ip! NULL) return $ ip; if (isset ($ _ SERVER [HTTP_X_FORWARDED_FOR]) {$ arrexplode (, $ _ SERVER [HTTP _ // Obtain the client ip address
Function get_client_ip (){
Static $ ip = NULL;
If ($ ip! = NULL) return $ ip;
If (isset ($ _ SERVER ['http _ X_FORWARDED_FOR ']) {
$ Arr = explode (',', $ _ SERVER ['http _ X_FORWARDED_FOR ']);
$ Pos = array_search ('Unknown ', $ arr );
If (false! ==$ Pos) unset ($ arr [$ pos]);
$ Ip = trim ($ arr [0]);
} Elseif (isset ($ _ SERVER ['http _ CLIENT_IP ']) {
$ Ip = $ _ SERVER ['http _ CLIENT_IP '];
} Elseif (isset ($ _ SERVER ['remote _ ADDR ']) {
$ Ip = $ _ SERVER ['remote _ ADDR '];
}
// Valid IP Address Verification
$ Ip = (false! = Ip2long ($ ip ))? $ Ip: '0. 0.0.0 ';
Return $ ip;
}
From the column lpdx111
Http://www.bkjia.com/PHPjc/478169.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478169.htmlTechArticle// get client ip address function get_client_ip () {static $ ip = NULL; if ($ ip! = NULL) return $ ip; if (isset ($ _ SERVER [HTTP_X_FORWARDED_FOR]) {$ arr = explode (, $ _ SERVER [HTTP _...