MANUAL DE PHP

(y algo mas)windsurf pozo izquierdo
Google
search for in the  
ELMARRAJO.COM mysql bulma desarrollo web linux fedora html ayuda

windsurf mercedes camper

gethostbyname

(PHP 3, PHP 4, PHP 5)

gethostbyname --  Obtener la dirección IP correspondiente a un nombre de host de Internet dado

Descripción

string gethostbyname ( string nombre_host )

Devuelve la dirección IP del host de Internet especificado por nombre_host o una cadena que contiene el valor nombre_host sin modificar si la función falla.

Ejemplo 1. Un ejemplo sencillo de gethostbyname()

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

echo
$ip;
?>

Vea también gethostbyaddr(), y gethostbynamel().



add a note add a note User Contributed Notes
gethostbyname
mmucklo at yahoo dot com
16-Aug-2006 11:05
One note about using gethostbyname() for checking email address domains:

If the name doesn't resolve, follow up with getdnsrr() and make sure they don't have an MX entry before returning an error.

It is possible for a domain name not to have an A record, but still have an MX entry.
Marc M
08-Aug-2006 08:33
Just a heads up. I was using this function on my site to verify email host addresses. I thought all was good, until a potential client contacted me and said they couldn't sign up correctly. They have a valid email address and domain, but this function failed.

Good luck.
ralphbolton at mail2sexy dot com
06-Apr-2006 01:10
On a side-note, PHP (5.0.4, but probably other versions too) can cache gethostbyname information.

In short, once PHP looks up an address, it may not actually perform another lookup as you may expect. In my particular case (I think) the problem was a change to resolv.conf didn't take effect inside PHP (although nslookup/ping etc worked fine). Stop/Starting Apache fixed it (although a simple 'restart' (kill -HUP) didn't).

In short, if you change resolv.conf, stop and restart Apache.
ivan[DOT]pirog[AT]gmail[DOT]com
14-Mar-2006 06:57
Function returns boolean:
<?php
function isDomainResolves($domain)
{
     return
gethostbyname($domain) != $domain;
}
?>
mcgrof at gmail dot com
21-Oct-2005 09:10
Better yet:
<?php
$ip
= rtrim(`/usr/bin/dig $host A +short`);
?>
mcgrof at gmail dot com
21-Oct-2005 09:05
In PHP4 you can use gethostbyname() but I have found this unreliable when doing lookups on entries that return A records on the private network. PHP5 has a much better routine -- dns_get_record(). If you are stuck with PHP4 or don't want to upgrade you can use dig:

<?php
$ip
= `/usr/bin/dig $host A +short`;
?>
tabascopete78 at yahoo dot com
18-Aug-2005 12:29
I was using file_get_contents on a set of URLs. Some of them URLs were invalid (the structure of it was ok but the DNS hosts couldn't resolve them) and I kept getting an annoying warning. I wanted to check the DNS somehow but existing check dns function in php doesn't have one for windows and the one a person supplied there does not work 100% of the time.

Instead use this function to try to resolve a host. This won't throw any warnings, you just need to check the output. You'll get the same warnings with fopen and fsockopen.
cox at idecnet dot com
26-Dec-2004 12:15
For doing basic RBL (Real Time Blacklist) lookups with this function do:

<?php
$host
= '64.53.200.156';
$rbl  = 'sbl-xbl.spamhaus.org';
// valid query format is: 156.200.53.64.sbl-xbl.spamhaus.org
$rev = array_reverse(explode('.', $host));
$lookup = implode('.', $rev) . '.' . $rbl;
if (
$lookup != gethostbyname($lookup)) {
   echo
"ip: $host is listed in $rbl\n";
} else {
   echo
"ip: $host NOT listed in $rbl\n";
}
?>

Tomas V.V.Cox
Vincent
14-Jul-2004 09:14
Note that if you pass an IP address to gethostbyname() it will return that IP address.
30-Mar-2004 02:49
The dns entries get cached, whether they exist or not.  Expect really good response times after the first one.
christian at SPAM at IS at DEAD at MEAT at karg dot org
01-Apr-2003 04:12
I had difficulty getting gethostbyname to work under OpenBSD 3.2 and Apache, until I discovered that the default Apache chroot caused the problem.

To get PHP's gethostbyname to work, you need resolv.conf (and possibly hosts) in /var/www/etc (assuming default install dirs).
tonyhana at sixzeros dot com
04-Jul-2002 07:43
<?php
//script to time DNS propagation
//(Above script modified slightly to show micro time)
//seems pretty damn quick to me.. I'm getting .0055 sec worstcase badhost times.

//A known good dns name (my own)
  
$nametotest = "fuzzygroup.com";
  
//Call address test function
  
$time_start = getmicrotime();
  
testipaddress($nametotest);
  
$time_end = getmicrotime();
  
$time = $time_end - $time_start;
   echo
"Good Host Search took $time seconds<br><br>";

//A known bad name (trust me)
  
$nametotest = "providence.mascot.com";
  
$time_start = getmicrotime();
  
testipaddress($nametotest);
  
$time_end = getmicrotime();
  
$time = $time_end - $time_start;
   echo
"Bad Host Search took $time seconds<br>";
  
  
function
getmicrotime(){
   list(
$usec, $sec) = explode(" ",microtime());
   return ((float)
$usec + (float)$sec);
   }

//ip address checking function
//for real use should have a return value but example code
function testipaddress ($nametotest) {
  
$ipaddress = $nametotest;
  
$ipaddress = gethostbyname($nametotest);
   if (
$ipaddress == $nametotest) {
       echo
"No ip address for host<br>";
   }
   else {
       echo
"good hostname, $nametotest ipaddress = $ipaddress<br>";
   }
}

//Recommended fix for sql applications:
// store url to temporary table
// run second process periodically to
// check urls and update main table
?>
sjohnson at fuzzygroup dot com
16-Mar-2002 10:27
<?php

//script to see if host exists on Internet

//following up on the above point about host name
//checking and SQL timeouts, run this test script
//and see how long it takes for 2nd call to
//hostname check to fail
//NOTE -- not PHP's fault -- nature of DNS

//A known good dns name (my own)
  
$nametotest = "fuzzygroup.com";
  
//Call address test function
  
testipaddress($nametotest);

//A known bad name (trust me)
  
$nametotest = "providence.mascot.com";
//Call address test function
  
testipaddress($nametotest);
  
//ip address checking function
//for real use should have a return value but example code
function testipaddress ($nametotest) {
  
$ipaddress = $nametotest;
  
$ipaddress = gethostbyname($nametotest);
   if (
$ipaddress == $nametotest) {
       echo
"No ip address for host, so host "
            
. "not currently available in DNS and "
            
. "probably offline for some time<BR>";
   }
   else {
       echo
"good hostname, ipaddress = $ipaddress<BR>";
   }
}

//Recommended fix for sql applications:
// store url to temporary table
// run second process periodically to
// check urls and update main table
?>

Citas célebres

Los poetas son magníficos para decirte dónde está el alma del país.

Inge Morath
Fotógrafa austríaca
(1923-2002)
Citas en tu mail
©Contenidos Gratis

Ilusiones Opticas
ilusion_optica_043.jpg
Contenidos Web

Chiste de... Parejas
Preparando el divorcio

Una pareja esta preparando el divorcio:

- (mujer) Yo me quedo con el crío.

- (marido) ¿Y eso por qué?

- Pues porque es mio, no tuyo.

- ... pero si tampoco es tuyo!

- ¿Cómo que no? ¿y quién lo parió?

- No sé. ¿Tú te acuerdas del día que nació, estando en maternidad, que se cagó y me dijiste que le cambiara?

- Sí.

- ¡Pues LE CAMBIÉ!
Chistes en tu mail
©ContenidosGratis

Humor Gráfico
humor_grafico_052.jpg
Contenidos Web

Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos
Cake ManiaCake Mania
Jugadores: 6835
Categoría del juego: Acción
Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero.
Rainbow WebRainbow Web
Jugadores: 2199
Categoría del juego: Puzzles
Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente.
Mahjongg FortunaMahjongg Fortuna
Jugadores: 12462
Categoría del juego: Solitarios
Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta.
Chainz 2Chainz 2
Jugadores: 6955
Categoría del juego: Puzzles
Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más.
DeliciousDelicious
Jugadores: 4405
Categoría del juego: Acción
Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues!
BookwormBookworm
Jugadores: 4568
Categoría del juego: Palabras
Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos!
ZumaZuma
Jugadores: 4976
Categoría del juego: Acción
Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás!
Jewel of AtlantisJewel of Atlantis
Jugadores: 3798
Categoría del juego: Puzzles
Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis.
Jewel QuestJewel Quest
Jugadores: 3727
Categoría del juego: Puzzles
Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos!
Bejeweled 2Bejeweled 2
Jugadores: 3659
Categoría del juego: Puzzles
Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca.
Contenidos gratis en tu webSiguiente >>

Fotos divertidas
fotos_increibles_0202.jpg
Contenidos Web
microrobots avion deportes riesgo recetas cocina canaria juegos online gratis moto motociclismo horoscopos naranjas valencianas surf canarias montañismo ciudades turismo postales gratis library Horoscopos Diarios Windsurf Canarias
fregadero microondas placa electrica bañopreparar camper pantalla plananevera compresor electricacamper fiat ducato camper baño quimicomampara enrollable bañocamper aire climatizadofurgoneta surf windsurffurgoneta surf windsurftelevisor furgonetas camperfurgonetas camper cama

Sudoku del día
Nivel de dificultad: Fácil



Cómo jugar:
El juego consiste en colocar los números del 1 al nueve de tal forma que no se repita el mismo número en la columna, fila y caja (bloques 3x3 enmarcados).

©Contenidos Gratis | Sudoku en tu mail
Sucedió el...

30 de agosto de 1617

Fallece Santa Rosa de Lima, por la que se celebra el "Día de la Patrona de América".
Efemérides en tu mail
©Contenidos Gratis
windsurf canarias youtube porno canarias baleares valencia madrid fallera mayor campus party alcacer feria valencia fernando alonso loterias dinero inversiones violencia de genero makro empresas cartera soledad tolerancia metro valencia gobierno de españa violencia de genero UIMP navidad