IP Address of visitor's connection

Returns the IP address of the visitor's connection.

//Return the visitor's IP address
function get_ip(){
 if (isset($_SERVER["REMOTE_ADDR"]))
 { 
 $ip=$_SERVER["REMOTE_ADDR"] . ' '; 
 } else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) { 
 $ip=$_SERVER["HTTP_X_FORWARDED_FOR"] . ' '; 
 } else if ( isset($_SERVER["HTTP_CLIENT_IP"]) ) { 
 $ip=$_SERVER["HTTP_CLIENT_IP"] . ' '; 
 }
 return $ip;
}


Usage


Comments

Add your comment