Re: Validar Link
| From: | Àngel Fenoy | Date: | Mon, 23 Sep 2002 15:01:21 +0000 |
| Subject: | Re: Validar Link | ||
| References: | 1 2 3 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-27231@lists.php.net to get a copy of this message | ||
Dilluns Setembre 23 2002 16:26, Alex Marin dixit:
> tambien me sirve, pero me arroga error cuando el sitio no existe, otra
> cosa se puede poner un timeout, por que se demora mucho cuando un sitio
> esta abajo
Puedes usar el operador @ para 'esconder' el error:
http://www.php.net/manual/en/language.operators.errorcontrol.php
En cuanto al timeout, no, las funciones de ficheros no tienen timeout. Si solo
te interesa saber si el sitio está caido o no, puedes usar una versión muy
simplificada del ejemplo que te puse ayer, para 5 segundos de timeout podrias
hacer algo así:
<?
if ($f = fsockopen("www.metunas.co.cu", 80, $errno, $errstr, 5)) {
fclose($f);
echo "Hola, el sitio esta ok!";
} else {
echo "Hola, el sitio no esta ok!<br>";
echo "Código de error: <b>$errno, $errstr</b>";
}
?>
Saludos
Àngel