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 :: rename file php 
Php :: laravel where is null 
Php :: create laravel project using laravel installer 
Php :: laravel db does not exists 
Php :: strtolower php 
Php :: php copy image from one folder to another 
Php :: php carbon get timestamp 
Php :: php is numeric 
Php :: jdate get one day before php 
Php :: encryption key has not encrypted laravel 
Php :: php array get first x elements 
Php :: how to get javascript variable value in php 
Php :: laravel validation unique email 
Php :: php ping test 
Php :: pause php 
Php :: php set header content type html 
Php :: symfony get current datetime 
Php :: php array_map with anonymous function 
Php :: phpspreadsheet setcellvalue row background color 
Php :: laravel carbon human readable 
Php :: how to get array dont similer elements in php 
Php :: php loop through string 
Php :: laravel validation integer 
Php :: how to debug php 
Php :: php check if variable is int 
Php :: the requested url was not found on this server. laravel 
Php :: php get date using timezone 
Php :: php header location to same page 
Php :: combine array except common ones php 
Php :: laravel go back to previous page blade 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =