ip undefined on some system [closed]

  laravel, laravel-5, php

I’m getting ip using this php code

  $ip="";
        if (!empty($_SERVER['HTTP_CLIENT_IP']))
        {
          $ip=$_SERVER['HTTP_CLIENT_IP'];
        }
        elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
        {
          $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
        }
        else if(!empty($_SERVER['HTTP_FORWARDED_FOR']))
        {
          $ip=$_SERVER['HTTP_FORWARDED_FOR'];
        }
        else if(!empty($_SERVER['HTTP_FORWARDED']))
        {
          $ip=$_SERVER['HTTP_FORWARDED'];
        }
        else if(!empty($_SERVER['REMOTE_ADDR']))
        {
          $ip=$_SERVER['REMOTE_ADDR'];
        }
        else
        {
           $ip="Unknown";
        }

but on some system i’m not getting any ip,

Any suggestion Thanks

Source: Laravel

Leave a Reply