PHP – How to get IP Address of an user

To check end user IP address in PHP, you can use this code.

<?php 
function getUserIpAddr(){
    if(!empty($_SERVER['HTTP_CLIENT_IP'])){
        //ip from internet without a proxy
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
        //ip pass from proxy infront of 
        $ip = 
Read more