Inspiration For Creative Minds
Home » Labs » How to get client’s IP address in PHP  

Filed under Labs

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;
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: