PHP | geoip_db_avail() Function

The geoip_db_avail() function is an inbuilt function in PHP which is used to check whether a GeoIP database is available or not. The function does not consider the proper existence of a file instead it checks whether it is readable or not.

Syntax:

bool geoip_db_avail( $database )

Parameters: This function accepts a single parameter $database which is integer type and it requires GeoIP database (GeoIP refers to the method of locating a computer terminal’s geographic location by identifying the terminal’s IP address. GeoIP can point a terminal location to a city, it requires the use of a GeoIP database).

Return Values: This function returns True on success (if the database exists) or False on failure (if the database is not found) and returns NULL if an error is encountered.

Below programs illustrate the geoip_db_avail() function in PHP:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code implementing geoip_db_avail() function
  
// Checks if the database entered is valid or not
if (geoip_db_avail(GEOIP_COUNTRY_EDITION))
    echo "True";
?>

chevron_right


Output:

True

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code implementing geoip_db_avail() function
  
// Checks if the database entered is valid or not
if (geoip_db_avail(GEOIP_ORG_EDITION))
    echo "True";
?>

chevron_right


Output:

True

Related Articles:

Reference: http://php.net/manual/en/function.geoip-db-avail.php

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.