PHP | geoip_db_filename() Function

The geoip_db_filename() function is an inbuilt function in PHP, which is used to generate the filename for corresponding GeoIP database accepted as a parameter. The function will not indicate the existence of file on the disk instead will just return the filename where the library is searching the database.
Syntax:
string geoip_db_filename ( $database )
Parameter: This function accepts single parameter $database which is mandatory. The database type are integer. There are various predefined constants which are used as database listed below:
- GEOIP_COUNTRY_EDITION
- GEOIP_REGION_EDITION_REV0
- GEOIP_CITY_EDITION_REV0
- GEOIP_ORG_EDITION
- GEOIP_ISP_EDITION
- GEOIP_CITY_EDITION_REV1
- GEOIP_REGION_EDITION_REV1
- GEOIP_PROXY_EDITION
- GEOIP_ASNUM_EDITION
- GEOIP_NETSPEED_EDITION
- GEOIP_DOMAIN_EDITION
The following constants are used for net speed:
- GEOIP_UNKNOWN_SPEED
- GEOIP_DIALUP_SPEED
- GEOIP_CABLEDSL_SPEED
- GEOIP_CORPORATE_SPEED
Return Value: This function returns the filename of the corresponding GeoIP database on success or NULL on failure/error.
Below programs illustrate the geoip_db_filename() function in PHP:
Program 1:
| <?php  // PHP code implementing the geoip_db_filename() function   // The function takes the database and returns //  the filename according to the database printgeoip_db_filename(GEOIP_COUNTRY_EDITION); ?>  | 
Output:
/usr/share/GeoIP/GeoIP.dat
Program 2:
| <?php $arr= array(              'GEOIP_COUNTRY_EDITION'=> GEOIP_COUNTRY_EDITION,              'GEOIP_REGION_EDITION_REV1'=> GEOIP_REGION_EDITION_REV1,              'GEOIP_PROXY_EDITION'=> GEOIP_PROXY_EDITION,              'GEOIP_ASNUM_EDITION'=> GEOIP_ASNUM_EDITION,              'GEOIP_DOMAIN_EDITION'=> GEOIP_DOMAIN_EDITION,              'EOIP_UNKNOWN_SPEED'=> GEOIP_UNKNOWN_SPEED,              'GEOIP_DIALUP_SPEED'=> GEOIP_DIALUP_SPEED,              'GEOIP_CABLEDSL_SPEED'=> GEOIP_CABLEDSL_SPEED,              'GEOIP_CORPORATE_SPEED'=> GEOIP_CORPORATE_SPEED              );  foreach($arras$val) {     echogeoip_db_filename($val) . (geoip_db_avail($val) ? 'Available':'') . '<br>'; } ?>  | 
Output:
/usr/share/GeoIP/GeoIP.datAvailable /usr/share/GeoIP/GeoIPRegion.dat /usr/share/GeoIP/GeoIPProxy.dat /usr/share/GeoIP/GeoIPASNum.dat /usr/share/GeoIP/GeoIPDomain.dat /usr/share/GeoIP/GeoIP.datAvailable /usr/share/GeoIP/GeoIPCity.dat /usr/share/GeoIP/GeoIPRegion.dat
Related Articles:
Reference: http://php.net/manual/en/function.geoip-db-filename.php
 
				 
					

