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

Basic PHP tutorial

Advanced PHP tutorial

PHP & MySQL

PHP reference manual

Usage and example of PHP gethostbyaddr() function

PHP HTTP  reference manual

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

Syntax

string gethostbyaddr ( string $ip_address )

Definition and usage

Used to obtain the IP address for the given Internet host name

Return value

 Returns the host name if successful; if failed, returns the original output (output IP address); if the input format is abnormal, 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 host name

PHP HTTP  reference manual