PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > checking for broken URLs with PHP?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
checking for broken URLs with PHP?

Réponse
 
LinkBack Outils de la discussion
Vieux 13/11/2007, 12h00   #1
AK
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut checking for broken URLs with PHP?

Hi,

Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.

A bare-bones example would be appreciated.

Thanks!

  Réponse avec citation
Vieux 13/11/2007, 14h56   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: checking for broken URLs with PHP?

On 13 Nov, 11:00, AK <danr...@gmail.com> wrote:
> Hi,
>
> Can anyone tell me how to connect to a URL using PHP for the purpose
> of obtaining the HTTP response code? Specifically, I want to be able
> to ascertain whether a link is down (404) or alive.
>
> A bare-bones example would be appreciated.
>
> Thanks!


Try typing
php http request
into Google

  Réponse avec citation
Vieux 13/11/2007, 17h32   #3
igrosny@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: checking for broken URLs with PHP?

On Nov 13, 8:00 am, AK <danr...@gmail.com> wrote:
> Hi,
>
> Can anyone tell me how to connect to a URL using PHP for the purpose
> of obtaining the HTTP response code? Specifically, I want to be able
> to ascertain whether a link is down (404) or alive.
>
> A bare-bones example would be appreciated.
>
> Thanks!


Perhaps this could

http://ar.php.net/manual/en/function.fopen.php#58099

  Réponse avec citation
Vieux 14/11/2007, 01h09   #4
Csaba Gabor
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: checking for broken URLs with PHP?

On Nov 13, 12:00 pm, AK <danr...@gmail.com> wrote:
....
> Can anyone tell me how to connect to a URL using PHP for the purpose
> of obtaining the HTTP response code? Specifically, I want to be able
> to ascertain whether a link is down (404) or alive.
>
> A bare-bones example would be appreciated.


<?php
file_get_contents("http://google.com");
var_dump($http_response_header);
?>


Csaba Gabor from Vienna

  Réponse avec citation
Vieux 14/11/2007, 13h46   #5
AK
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: checking for broken URLs with PHP?

On Nov 14, 12:09 am, Csaba Gabor <dans...@gmail.com> wrote:
> On Nov 13, 12:00 pm, AK <danr...@gmail.com> wrote:
> ...
>
> > Can anyone tell me how to connect to a URL using PHP for the purpose
> > of obtaining the HTTP response code? Specifically, I want to be able
> > to ascertain whether a link is down (404) or alive.

>
> > A bare-bones example would be appreciated.

>
> <?php
> file_get_contents("http://google.com");
> var_dump($http_response_header);
> ?>
>
> Csaba Gabor from Vienna


Thanks, that's the sort of "quick solution" I was looking for
(although I managed to find it myself after a bit of digging:
$arr = get_headers("http://www.google.com");
is even more concise)

Thanks to the previous responses as well, including the one that
suggested using a quaint little thing that seems to have the amazing
ability to search through web pages! (Google, I think it's called... )

Cheers

  Réponse avec citation
Vieux 15/11/2007, 11h38   #6
Lars Eighner
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: checking for broken URLs with PHP?

In our last episode,
<1194951649.555713.91490@k79g2000hse.googlegroups. com>,
the lovely and talented AK
broadcast on comp.lang.php:

> Hi,


> Can anyone tell me how to connect to a URL using PHP for the purpose
> of obtaining the HTTP response code? Specifically, I want to be able
> to ascertain whether a link is down (404) or alive.


> A bare-bones example would be appreciated.


> Thanks!


Is there some reason searching the manual index on 'http' did not turn up
http_head for you?

--
Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner>
Countdown: 432 days to go.
What do you do when you're debranded?
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h49.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11670 seconds with 14 queries