Thursday, November 20, 2025
HomeLanguagesPHP | geoip_asnum_by_name() Function

PHP | geoip_asnum_by_name() Function

The geoip_asnum_by_name() is an inbuilt function in PHP which helps us to get the Autonomous System Number (ASN). The function will help us to get the ASN by taking an IP address as an argument .

Syntax :

string geoip_asnum_by_name ( string $hostname )

    Parameters : The function accepts a single parameter as mentioned above and explained below :

  • $hostname : It is the only parameter accepted by the geoip_asnum_by_name() function. It is the IP address or the hostname which the function accepts and returns the ASN(Autonomous Syntax Number).

Return Values : It returns the ASN(Autonomous Syntax Number) on success and FALSE on failure.

Below program illustrate the geoip_asnum_by_name() function.
Program :




<?php
  
// PHP code to illustrate the
// geoip_asnum_by_name() function
  
// The function accepts the host 'www.example.com'
$asn = geoip_asnum_by_name('www.example.com');
  
if ($asn) {
  
     //the function will print the ASN 
     echo 'The ASN is:'.$asn;
}
?>


Output:

The ASN is: AS15133 EdgeCast Networks, Inc

Reference : http://php.net/manual/en/function.geoip-asnum-by-name.php

RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6777 POSTS0 COMMENTS
Nicole Veronica
11925 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6905 POSTS0 COMMENTS
Ted Musemwa
7162 POSTS0 COMMENTS
Thapelo Manthata
6861 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS