Home » Web Design » Web Development – PHP Code for Identifying End User

Web Development – PHP Code for Identifying End User

Client IP Demo

Your IP address : 54.92.197.82
Your hostname : ec2-54-92-197-82.compute-1.amazonaws.com

——————-

There is no Forwarding IP found.

——————-

If we look at the php code to identify the IP, we see the following.

$ip = $_SERVER[‘REMOTE_ADDR’];
echo “<h2>Client IP Demo</h2>”;
echo “Your IP address : ” . $ip;
echo “<br>Your hostname : “. gethostbyaddr($ip) ;

Breaking the code down:

$ip = $_SERVER[‘REMOTE_ADDR’];

The Server information is first placed in the variable $ip.

echo “<h2>Client IP Demo</h2>”;

The echo is simply sending out the string as header 2 size.

echo “Your IP address : ” . $ip;

This echo gives the string “Your IP Address :” The provided value in variable $ip is then given to us.

echo “<br>Your hostname : “. gethostbyaddr($ip) ;

The main value provided here is the host name, from the parameter “gethostbyaddr” for the variable $ip.


Leave a comment

Your email address will not be published. Required fields are marked *