Get the Client's IP Address

This is a way to retrieve a client's IP address whether it be a shared client, proxy, or standard. I've found it to be exceptionally handy to use with form posts.

                                function getIp(){
    //Test if it is a shared client
    if (!empty($_SERVER['HTTP_CLIENT_IP'])){
        $ip=$_SERVER['HTTP_CLIENT_IP'];
    //Is it a proxy address
    }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
        $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}