Advertisement
Corey

Untitled

May 18th, 2020
2,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.     function getCountry()
  3.     {
  4.         if(isset($_SERVER["GEOIP_COUNTRY_NAME"]))
  5.         {
  6.             $country = $_SERVER["GEOIP_COUNTRY_NAME"];
  7.         }
  8.         elseif(isset($_SERVER["GEOIP_COUNTRY_CODE"]))
  9.         {
  10.             $country = $_SERVER["GEOIP_COUNTRY_CODE"];
  11.         }
  12.         elseif(isset($_SERVER["HTTP_CF_IPCOUNTRY"]))
  13.         {
  14.             $country = $_SERVER["HTTP_CF_IPCOUNTRY"];
  15.         }
  16.         else
  17.         {
  18.             $country = "ERROR: No Country Detected.";
  19.         }
  20.         return $country;
  21.     }
  22.  
  23.     $country = getCountry();
  24.     echo $country;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement