You can familiarize yourself with  Sypex Geo 2.2 format specification.


1. Copy SxGeo.php and SxGeo.dat (or SxGeoCity.dat or other databases) to server
2. Include the SxGeo.php file in your script by adding the line


3. Create an SxGeo object

// The first parameter is the name of the file with the database (the Sypex Geo binary database is used)
// The second parameter is the operating mode:
//  SXGEO_FILE   (working with a database file, default mode);
//  SXGEO_BATCH  (batch processing, increases speed when processing many
//                IP at a time);
//  SXGEO_MEMORY (caching the database in memory also increases the speed of batch processing,
//                but requires more memory to load the entire database into memory).

$SxGeo = new SxGeo(); // Default mode, database file SxGeo.dat
//$SxGeo = new SxGeo('SxGeo.dat', SXGEO_BATCH | SXGEO_MEMORY) ; // The fastest mode is batch mode

4. We define a country with a database containing countries (SxGeo Country)

$country = $SxGeo->getCountry($ip);  (returns the two-digit ISO country code)
// $SxGeo->getCountryId($ip); (returns the country number)

4. Define the city (SxGeo City, GeoLite City, IpGeoBase)

// $SxGeo->getCity($ip); (returns with brief information, without the name of the region and time zone)
// $SxGeo->getCityFull($ip); (returns complete information about the city and region)
$city = $SxGeo->get($ip); (performs getCountry or getCity depending on the database type)

5.  If you need to free up resources, delete the object