Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get user ip in php

function getIp() {
    $ip = $_SERVER['REMOTE_ADDR'];
 
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
 
    return $ip;
}
Comment

php get user ip address

#to best handle proxies use this:
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 {
    $ip = $_SERVER['REMOTE_ADDR'];
}
Comment

Get User IP address (PHP)

#php 7.x
<?php if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    echo $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    echo $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    echo $ip = $_SERVER['REMOTE_ADDR'];
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php string to array 
Php :: php array in cookie 
Php :: check if text exists in string php 
Php :: get the list of php versions installed 
Php :: get_user_meta 
Php :: what is app_env in laravel 
Php :: laravel validate telephone number 
Php :: laravel read json file from storage 
Php :: key of last element php 
Php :: laravel old request hmtl select 
Php :: remove phpmyadmin ubuntu 20.04 completely 
Php :: write if and else in one line php 
Php :: end session variable php 
Php :: install php7.4 in linux server 
Php :: laravel validation time hours minutes format 
Php :: base64 encode username password php example 
Php :: php max_execution_time 
Php :: Laravel loop with counter 
Php :: last login date time in wordpress 
Php :: wordpress PHPMailer config 
Php :: php yesterday 
Php :: rename file php 
Php :: get env app url laravel 
Php :: jdate get one day before php 
Php :: The mysqli extension is missing. Please check your PHP configuration. 
Php :: array con php 
Php :: array empty check in php 
Php :: php refresh page 
Php :: php remove all but numbers 
Php :: how to print query in laravel 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =