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

PHP | gethostbyname() Function

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
  
$ip = gethostbyname("geeksforgeeks.org");
  
echo $ip;
?>


Output:

52.25.109.230

Reference: https://www.php.net/manual/en/function.gethostbyname.php

RELATED ARTICLES

Most Popular

Dominic
32404 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6776 POSTS0 COMMENTS
Nicole Veronica
11924 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11994 POSTS0 COMMENTS
Shaida Kate Naidoo
6905 POSTS0 COMMENTS
Ted Musemwa
7160 POSTS0 COMMENTS
Thapelo Manthata
6861 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS