1The simplest way to collect the Client/Visitor IP address using PHP is the REMOTE_ADDR.
2Pass the 'REMOTE_ADDR' in PHP $_SERVER variable. It will return the IP address of the visitor who is currently viewing the webpage.
3
4Get the IP address of the website
5<?php
6echo 'User IP Address : '. $_SERVER['REMOTE_ADDR'];
7?>
8
9/*
10I Hope it will help you.
11Namaste
12Stay Home Stay Safe
13*/
1function get_client_ip() {
2 $ipaddress = '';
3 if (getenv('HTTP_CLIENT_IP'))
4 $ipaddress = getenv('HTTP_CLIENT_IP');
5
6 else if(getenv('HTTP_X_FORWARDED_FOR'))
7 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
8
9 else if(getenv('HTTP_X_FORWARDED'))
10 $ipaddress = getenv('HTTP_X_FORWARDED');
11
12 else if(getenv('HTTP_FORWARDED_FOR'))
13 $ipaddress = getenv('HTTP_FORWARDED_FOR');
14
15 else if(getenv('HTTP_FORWARDED'))
16 $ipaddress = getenv('HTTP_FORWARDED');
17
18 else if(getenv('REMOTE_ADDR'))
19 $ipaddress = getenv('REMOTE_ADDR');
20
21 else
22 $ipaddress = 'UNKNOWN';
23
24 return $ipaddress;
25}