Open In App

PHP | gethostbyname() Function

Last Updated : 29 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The gethostbyname() function is an inbuilt function in PHP which returns IPv4 address for a specified host/domain name. Syntax:
string gethostbyname( $hostname )
Parameter: This function accepts single parameter $hostname which is required. It specifies the hostname whose IPv4 address to be found. Return Value: This function returns the IPv4 address on success or string containing the unmodified hostname on failure. Note: This function is available for PHP 4.0.0 and newer versions. Below program illustrates the gethostbyname() function in PHP: Program: php
<?php

$ip = gethostbyname("geeksforgeeks.org");

echo $ip;
?>
Output:
52.25.109.230
Reference: https://www.php.net/manual/en/function.gethostbyname.php

Next Article

Similar Reads