Tuesday 4 April 2017

Find location from IP .

Create Function : 



function ipInfo($ip) {
 if(isset($ip)) {
      $data = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
    if($data['geoplugin_status'] == '200') {
     return $data;
    } else {
     echo "Bad request!, Error code is ".$data['geoplugin_status']; 
    }
 } else {
  echo "IP is not set!"; 
 }
}


Result : 
var_dump(ipInfo('180.151.74.202'));

No comments:

Post a Comment