Checking Links with php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SteveD
Forum Newbie
Posts: 3
Joined: Sat Jun 10, 2006 11:16 pm

Checking Links with php code

Post by SteveD »

I would like to make a php program that will take a list of URLs in all of my site's web pages and somehow "ping" (for lack of a better word) each site and return a value if they are still active.

I've seen services on the web that do this but there is always some shortcoming on them that I would like to fix. I have several books on php but honestly I don't even know where to begin for something like this. It must be possible. What commands should I start to look at (and learn about)?

TIA
Steve
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

php 5 has get_headers(), and you can use curl in php 4 to do the same thing, or fsockopen() if you're feeling daring.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Just for pinging, wouldnt gethostbyname do the job ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

anjanesh wrote:Just for pinging, wouldnt gethostbyname do the job ?
That would do a DNS lookup, not touch the server.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Yeah I think it would if all the links were in an array, and then if you do a for() statement with that it would work, I might be slow, but it would work.
Post Reply