Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get ip address of visitor

$clientIPAddress=$_SERVER['REMOTE_ADDR']; 
Comment

php ip address of visitor

<?PHP

function getUserIP()
{
    // Get real visitor IP behind CloudFlare network
    if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
              $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
              $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
    }
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }

    return $ip;
}


$user_ip = getUserIP();

echo $user_ip; // Output IP address [Ex: 177.87.193.134]


?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel make:listner 
Php :: laravel get list of columns in a table 
Php :: read key value json php 
Php :: string to float php 
Php :: how to remove token while logout using laravel 8 
Php :: get the current page id in wordpress 
Php :: double in migration laravel 
Php :: laravel db does not exists 
Php :: form validation nullable laravel 
Php :: php remove first and last char 
Php :: the configuration file now needs a secret passphrase (blowfish_secret) 
Php :: call metho din config laravel 
Php :: htaccess replace url parameter with slash prameter 
Php :: how to get javascript variable value in php 
Php :: laravel debugbar false not working 
Php :: CAPTURAR URL PHP 
Php :: get product category url woocommerce 
Php :: laravel collection tojson 
Php :: mobile no validation laravel 
Php :: Composer install : Your requirements could not be resolved to an installable set of packages 
Php :: wordpress logout redirect to home 
Php :: carbon set locale laravel 
Php :: In php, how to convert string value into an int 
Php :: Laravel factory avatars 
Php :: wordpress disable theme editor 
Php :: phph get server protocol 
Php :: composer symfony/var-dumper 
Php :: php version check code 
Php :: magento colloction query 
Php :: laravel previous url 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =