$_SERVER['REMOTE_ADDR'] 

 It returns the IP address of the user currently visiting the webpage.


 Many times we need to get the IP address of the visitor for different purposes. It is very easy to collect the IP address in PHP. PHP provides PHP $_SERVER variable to get the user IP address easily. We can track the activities of the visitor on the website for the security purpose, or we can know that who uses my website and many more.

The simplest way to collect the visitor IP address in PHP is the REMOTE_ADDR. Pass the 'REMOTE_ADDR' in PHP $_SERVER variable. It will return the IP address of the visitor who is currently viewing the webpage.

code:-

<?php  
echo 'User IP Address - '.$_SERVER['REMOTE_ADDR'];  
?>  

output:-

User IP Address - ::128.24.4.3

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post