Your IP address is 3.227.247.17 |
You are probably familiar with the WHOAMI
command.
This is a web version of that command
PHP Code: |
<?php $ip = $_SERVER['REMOTE_ADDR']; $xmlstr = file_get_contents( "http://www.webservicex.net/geoipservice.asmx/GetGeoIP?IPAddress={$ip}" ); $xml = new SimpleXMLElement( $xmlstr ); $rc = $xml->ReturnCode[0]; if ( $rc == 1 ) { $countryname = ucwords( strtolower( $xml->CountryName[0] ) ); $countrycode = $xml->CountryCode[0]; } else { $countryname = 'Unknown'; $countrycode = '--'; } print "<p>Your IP address is {$ip}<br>\n Your location is {$countryname} ({$countrycode})</p>"; ?> |
As you can see in the code, it is based on webservicex.net's GetGeoIP functionality.
Note: | A note from Stan Littlefield: for local use, replace $ip = $_SERVER['REMOTE_ADDR']; by $ip = file_get_contents('http://whatismyip.org/'); |
page last uploaded: 2018-12-20, 10:50