Thursday, October 23, 2025
HomeLanguagesPHP | gethostbyaddr() function

PHP | gethostbyaddr() function

The gethostbyaddr() function is an inbuilt function in PHP which returns domain name for a specified IP address.

Syntax:

gethostbyaddr($ip_address);

Parameter: This function accepts one parameter as mentioned above and described below:

  • $ip_address: It is required parameter. It specifies IP address whose host name to be found. Passed as a string.

Return Value:

  • This function returns hostname on success and IP address on failure.

Note:

  • This function is available for PHP 4.0.0 and newer version.

Example




<?php
$host = gethostbyaddr("52.25.109.230");
echo $host;
?>


Output:

ec2-52-25-109-230.us-west-2.compute.amazonaws.com

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS