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 :: how to get variable from url in laravel 
Php :: how to take last entry in database in laravel Method ONe 
Php :: Call to undefined method IlluminateSessionStore::set() 
Php :: foreign key in laravel 
Php :: php foreach mysql result 
Php :: print url in view yii2 
Php :: wp enqueue style for style.css 
Php :: use class Auth larave3l 
Php :: how to pass variable in inside function into where in laravel 
Php :: Calculate the Difference Between Two Dates Using PHP 
Php :: woocommerce get post terms product 
Php :: laravel serve in another port 
Php :: wordpress get field 
Php :: if exist php 
Php :: php find text in variable 
Php :: post type taxonomy loop wordpress 
Php :: loop index foreach laravel 
Php :: bin to dec php 
Php :: http error code php 
Php :: laravel storage get file path 
Php :: sort multidimensional array php by key 
Php :: page expire in laravel 
Php :: getting last day of next month in php 
Php :: convert date php 
Php :: cookie are not set in php 
Php :: laravel json search 
Php :: php loop through array of objects 
Php :: capitalize php 
Php :: how to replace multiple characters in a string in php 
Php :: ubuntu install lamp and phpmyadmin 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =