Get ip address of the visitor - Php

get ip address

Snippet Code


  
Rate this page :
  [ 0 votes]

The above code is used to get the ip address of the visitor

function getIP(){ if (!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else{ $ip = $_SERVER['REMOTE_ADDR']; } return $ip; }

Tags


Ask Questions

Ask Question