The following user-defined function is used to get the client system IP address. In case of tracking purpose, we can use the following function in order to get the client system IP address.
For example, you are working in a network and you have a web page and you plan to add more security to that page. If you want to track what system the web page was seen from, you can use the following function.
function getRealIpAddr() {
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'];
}
return $ip;
}
Take this function and experiment with it.
|