gethostbyname

(PHP 4, PHP 5)

gethostbyname Obtener la dirección IPv4 que corresponde a un nombre de host de Internet dado

Descripción

string gethostbyname ( string $hostname )

Devuelve la dirección IPv4 del host de Internet especificado por hostname.

Parámetros

hostname

El nombre de host.

Valores devueltos

Devuelve la dirección IPv4 o un string que contiene el hostname sin modificar en caso de error.

Ejemplos

Ejemplo #1 Ejemplo simple de gethostbyname()

<?php
$ip 
gethostbyname('www.example.com');

echo 
$ip;
?>

Ver también

  • gethostbyaddr() - Obtener el nombre del host de Internet correspondiente a una dirección IP dada
  • gethostbynamel() - Obtener una lista de direcciones IPv4 que corresponde a un nombre de host de Internet dado
  • inet_pton() - Converts a human readable IP address to its packed in_addr representation
  • inet_ntop() - Converts a packed internet address to a human readable representation