How to get client’s IP address in PHP

Some times you need to track the visitors IP address for a particular reason. Here is some PHP codes which is usfun for those projects which needs to track IP address.

What is your IP Address

echo "Your IP Address is : = $ipaddress";

The above code will display your IP address.


//Return the visitor's IP address
function get_ip(){
 if (isset($_SERVER["REMOTE_ADDR"]))
 $ip=$_SERVER["REMOTE_ADDR"] . ' '; 
 } else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) { 
 } else if ( isset($_SERVER["HTTP_CLIENT_IP"]) ) { 
 $ip=$_SERVER["HTTP_CLIENT_IP"] . ' '; 
 return $ip;
Tags: ,

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …

Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us