IP variables for the client:
$_server[' REMOTE_ADDR ': Client IP, may also be proxy IP
$_server[' http_client_ip ': Proxy-side IP, may exist, may also be forged
$_server[' http_x_forward_for ': The ID that the user uses on which IP, may exist, or may be forged
IP variables on the server side:
$_server[' server_name ': You need to use the function gethostname () to get it, whether it is the server side or the client can display normally.
$_server[' server_addr ': Server-side IP address, test IP address on server side, test normal on client
Getnev get the environment variables for the system:
Example:
<?phpclass GetIP () { function ClientIP () { $cIP = getenv ($_server[' remote_addr ']); $cIP 1 = getenv ($_server[' http_x_forword_for '); $cIP 2 = getenv ($_server[' http_client_ip '); $cIP 1? $cIP = $cIP 1?null; $cIP 2? $cIP = $cIP 2?null; return $cIP;} function ServerIP () { return gethostbyname ($_server[' server_name ');}} $getIP = new GetIP (); $clientIp = Getip::clientip (); $serverIp = Getip::serverip (); ? >
PHP gets client and server-side IP