PHP Classes

File: php/getLocation.php

Recommend this page to a friend!
  Classes of bamigboye biodun   Logical Functions   php/getLocation.php   Download  
File: php/getLocation.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Logical Functions
General-purpose PHP and JavaScript functions
Author: By
Last change:
Date: 1 year ago
Size: 608 bytes
 

Contents

Class file image Download
<?php
function getUserLocation(string $ip = false): string
{
  if (
$ip === false) $ip = $_SERVER['REMOTE_ADDR'] ?? false;
  if (!
$ip) return 'ip_not_found';
  return
unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
}

var_dump(getUserLocation('129.205.114.36'));
     
/*
        @author : Biodun Bamigboye

        Credit : http://www.geoplugin.net

      Location Currency, Conversion Rate, Region City
      , Map Co-ordinate, Time Zone , Continent, Country Code
       
      Note That this does not work on localhost.
      It has to be hosted on a server online

      */