Ashburn, June 27, 2017

How to get client’s IP of the users that visit your website

Here is a helpful function that will return the ip address of the users that visit your site.

             function get_real_up_address() {

                      if (isset($_SERVER)) {
                         if (isset($_SERVER[“HTTP_X_FORWARDED_FOR”]))
                              return $_SERVER[“HTTP_X_FORWARDED_FOR”];
                         if (isset($_SERVER[“HTTP_CLIENT_IP”]))
                              return $_SERVER[“HTTP_CLIENT_IP”];
                      return $_SERVER[“REMOTE_ADDR”];

                      if (getenv(“HTTP_X_FORWARDED_FOR”))
                         return getenv(“HTTP_X_FORWARDED_FOR”);
                      if (getenv(“HTTP_CLIENT_IP”))
                         return getenv(“HTTP_CLIENT_IP”);
                      if (getenv(“REMOTE_ADDR”))
                         return getenv(“REMOTE_ADDR”);                     

                      return “UNKNOWN”;


About Karlos Maldonado 36 Articles
Computer Sciences Engineer graduated from Florida Atlantic University (FAU) in Boca Raton, Florida. Has gotten great experience in the IT and Web Development industry working for companies such as SIRIUS XM RADIO, 4MEDIA as well as collaborating with local companies.

Be the first to comment

Leave a Reply

Your email address will not be published.