php get ip address of visitor code example

Example 1: php get location from ip address

$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $details->city; // -> "Mountain View"

Example 2: how to get ip address of client using php

The simplest way to collect the Client/Visitor IP address using 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.

Get the IP address of the website

  
/*
I Hope it will help you.
Namaste
Stay Home Stay Safe
*/

Example 3: php get ip address of visitor

$clientIPAddress=$_SERVER['REMOTE_ADDR'];

Tags:

Misc Example