How does php obtain the client ip address. Php: how to obtain the client ip address through ipphp. functiongetOnlineIP () {$ cipgetenv (HTTP_CLIENT_IP); $ xipgetenv (HTTP_X_FORWARDED_FOR); $ ripgetenv (how does php obtain the client ip address?
Php obtains the client ip address, which is simple and practical.
Function getOnlineIP (){
$ Cip = getenv ('http _ CLIENT_IP ');
$ Xip = getenv ('http _ X_FORWARDED_FOR ');
$ Rip = getenv ('remote _ ADDR ');
$ Srip = $ _ SERVER ['remote _ ADDR '];
If ($ cip & strcasecmp ($ cip, 'Unknown ')){
$ Onlineip = $ cip;
} Elseif ($ xip & strcasecmp ($ xip, 'Unknown ')){
$ Onlineip = $ xip;
} Elseif ($ rip & strcasecmp ($ rip, 'Unknown ')){
$ Onlineip = $ rip;
} Elseif ($ srip & strcasecmp ($ srip, 'Unknown ')){
$ Onlineip = $ srip;
}
// LieHuo. Net Tutorial
Preg_match ("/[\ d \.] {7, 15}/", $ onlineip, $ match );
$ Onlineip = $ match [0]? $ Match [0]: 'Unknown ';
Return $ onlineip;
}
Using php to obtain the client ip address, simple and practical function getOnlineIP () {$ cip = getenv ('http _ CLIENT_IP '); $ xip = getenv ('http _ X_FORWARDED_FOR '); $ rip = getenv (...