php get my ip address code example
Example 1: php get client ip
$_SERVER['REMOTE_ADDR']
Example 2: php get ip address
$clientIPAddress=$_SERVER['REMOTE_ADDR'];
Example 3: 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;
}