Today i discus on "how to get client pc ip address using PHP". Some time we need to get client pc ip address for security or other validation. Such as the voting system on online newspaper. Every day newspaper get only one vote form a ip address. So we need to get client ip address some time for some specific development purpose.
To get client ip address i create a function as following.
now test the code and enjoy it.
for any question
To get client ip address i create a function as following.
<?phpfunction getClientIpAddress()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ipadd=$_SERVER['HTTP_CLIENT_IP'];/*check ip from internet*/
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ipadd=$_SERVER['HTTP_X_FORWARDED_FOR'];/*check ip proxy*/
}
else{
$ipadd=$_SERVER['REMOTE_ADDR'];
}
return $ipadd;
}
echo getClientIpAddress(); // display IP address?>
now test the code and enjoy it.
for any question
Thanks to you for writing this wonderful article.
ReplyDeletecracked software free download
Nice and good post. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information.
ReplyDeletePhp Web Development Company Bangalore | Ecommerce In Bangalore | Internet Marketing Company in Bangalore | Magento Experts In India