Monday, November 17, 2014

How to Find IP Address With Using PHP Code

Check out, how to find the IP address of your computer with using php code. It is one of the basic things in php as well as very simple. Here, I am going to explain how to get the true ip address with only using php code. Let me explain in detail.

Find IP Address With Using PHP Code


Check out the code in detail :-

<?php
function getRealIpAddress()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
//check ip from internet
{
$ipadd=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
//check ip proxy
{
$ipadd=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ipadd=$_SERVER['REMOTE_ADDR'];
}
return $ipadd;
}
echo getRealIpAddress(); // display IP address
?>

0 comments:

Post a Comment