Open In App

PHP | Determining Client IP Address

What is an IP Address? 
The IP address stands for Internet Protocol Address. An IP address is used to provide an identity to a networked device.IP addresses allow the location of different digital devices that are connected to the Internet to be pinpointed and differentiated from other devices.

In this post we have discussed two different ways of determining the client IP address from a PHP script as explained below: 







<?php
 $ipaddress = getenv("REMOTE_ADDR") ;
 Echo "Your IP Address is " . $ipaddress;
?>

Output : 

Your IP is 127.1.1.0




<?php
 $ipaddress = $_SERVER['REMOTE_ADDR']
 Echo "Your IP Address is " . $ipaddress;
?>

Output : 



Your IP is 127.1.1.0

 

Article Tags :