How to get the client IP address in PHP

Prem Tiwari - - PHP Tutorials


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.

How to get the client IP address in PHP

Copy the below PHP code and use it inside your PHP script to print the IP address.

Output:

Your IP is 198.168.1.72