How to Get Remote IP Address in PHP

How to Get Remote IP Address in PHP

From today I’m going to introduce a new section called “Quick Tips” in my website. Here, I’ll share php/css/js/jQuery/WP snippets. It will be a fun. Let’s get started-

Quick Tips#1:

Today we are going to learn “How to Get Remote IP Address in PHP”. PHP has built-in facility to detect remote browser or IP address and other properties. These values are assigned to special variable. In this case, it is assigned to variable called REMOTE_ADDR. You can use any one of the following statement to obtained or read IP address:

function getRemoteIPAddress() {
    $ip = $_SERVER['REMOTE_ADDR'];
    return $ip;
echo getRemoteIPAddress(); // print your ip address.


Was this information useful? What other tips would you like to read about in the future? Share your comments, feedback and experiences with us by commenting below!

Back To Top