Open In App

PHP | geoip_asnum_by_name() Function

Last Updated : 03 Jul, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads