Sometimes you need to get the client side the IP address to implement some features in web application using PHP programming language. In this tutorial, we will share 2 line PHP code to get the client IP address.
Copy the below PHP code and use it inside your PHP script to print the IP address.
1 2 3 4 5 6 7 |
<?php /* * get the client IP address in PHP */ $ipaddress = $_SERVER['REMOTE_ADDR'] Echo "Your IP Address is " . $ipaddress; ?> |
Your IP is 198.168.1.72
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.