PHP | Determining Client IP Address Read Courses Improve Improve Improve Like Article Like Save Article Save Report issue Report 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: Using getenv() function: To get the IP Address,we use getenv(“REMOTE_ADDR”) command.The getenv() function in PHP is used for retrieval of values of an environment variable in PHP.It is used to return the value of a specific environment variable.Syntax : PHP <?php $ipaddress = getenv("REMOTE_ADDR") ; Echo "Your IP Address is " . $ipaddress; ?> Output : Your IP is 127.1.1.0 Determining IP Address using $_SERVER Variable Method : There is another way to get the IP Address by using the $_SERVER[‘REMOTE_ADDR’] or $_SERVER[‘REMOTE_HOST’] variables. The variable in the $_SERVER array is created by the web server such as apache and those can be used in PHP.Basically $_SERVER[‘REMOTE_ADDR’]gives the IP address from which the request was sent to the web server. Syntax : PHP <?php $ipaddress = $_SERVER['REMOTE_ADDR'] Echo "Your IP Address is " . $ipaddress; ?> Output : Your IP is 127.1.1.0 Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about! Last Updated : 30 Jul, 2021 Like Article Save Article Previous PHP | gmp_rootrem() Function Next PHP | MySQL WHERE Clause Share your thoughts in the comments Add Your Comment Please Login to comment...