Use this code
<code> function get_client_ip_server() { $ipaddress = ''; if ($_SERVER['HTTP_CLIENT_IP']) $ipaddress = $_SERVER['HTTP_CLIENT_IP']; else if ($_SERVER['HTTP_X_FORWARDED_FOR']) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; else if ($_SERVER['HTTP_X_FORWARDED']) $ipaddress = $_SERVER['HTTP_X_FORWARDED']; else if ($_SERVER['HTTP_FORWARDED_FOR']) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; else if ($_SERVER['HTTP_FORWARDED']) $ipaddress = $_SERVER['HTTP_FORWARDED']; else if ($_SERVER['REMOTE_ADDR']) $ipaddress = $_SERVER['REMOTE_ADDR']; else $ipaddress = 'UNKNOWN'; return $ipaddress; } </code>
I hope help you
‘::1’ means it is your localhost IP Address.
::1 == 127.0.0.1
You can try this one also.
<code><span class="pln">$ip</span><span class="pun">=</span><span class="pln">$_SERVER</span><span class="pun">[</span><span class="str">'REMOTE_ADDR'</span><span class="pun">];</span><span class="pln"> echo </span><span class="str">"IP address= $ip"</span><span class="pun">;</span></code>
If your application hosted on same machine from where you are trying to request it will always return ‘::1’, It means LocalHost. else it will return client IP Address.
‘::1’ means it is your localhost IP Address.
::1 == 127.0.0.1
You can try this one also.
<code><span class="pln">$ip</span><span class="pun">=</span><span class="pln">$_SERVER</span><span class="pun">[</span><span class="str">'REMOTE_ADDR'</span><span class="pun">];</span><span class="pln"> echo </span><span class="str">"IP address= $ip"</span><span class="pun">;</span></code>
If your application hosted on same machine from where you are trying to request it will always return ‘::1’, It means LocalHost. else it will return client IP Address.
‘::1’ means it is your localhost IP Address.
::1 == 127.0.0.1
You can try this one also.
<code><span class="pln">$ip</span><span class="pun">=</span><span class="pln">$_SERVER</span><span class="pun">[</span><span class="str">'REMOTE_ADDR'</span><span class="pun">];</span><span class="pln"> echo </span><span class="str">"IP address= $ip"</span><span class="pun">;</span></code>
If your application hosted on same machine from where you are trying to request it will always return ‘::1’, It means LocalHost. else it will return client IP Address.