hello dear visitors,
During my project, i need to find IP address of client, so i write PHP script to achieve that, and i also share it here.
<?php
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'];
}
echo $ip;
?>
Definition
$_SERVER is an array which holds information of headers, paths and script locations.
Note
if you have any doubt or suggestion then please leave comment here!