English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP gethostbyaddr() Function Usage and Example

PHP HTTP  Reference Manual

The gethostbyaddr() function retrieves the hostname corresponding to the specified IP address.

Syntax

string gethostbyaddr ( string $ip_address )

Definition and usage

Used to obtain the IP address of the given Internet hostname

Return value

 Returns the hostname if successful; if failed, it outputs the original (outputs the IP address); if the input format is abnormal, it returns FALSE.

Parameter

Serial numberParameters and descriptions
1

ip_address

The IP address of the host.

Online Example

Try the following example

<?php
   $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
   
   echo $hostname;
?>

The example above returns the result of the hostname

PHP HTTP  Reference Manual