Broken Link?

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
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Broken Link?

Post by Todd_Z »

Whats the fastest way to check if a url is a broken link?

I need to keep in mind that there are redirections too, so fopen doesn't work.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

PM me... You sound like you're working on something very very similar to something I did recently for a client.

Can't remember if I checked for dead links but you'll need the URL parser I posted to you (to parse any redirects into absolute URLs) and then you use fsockopen() (or curl_() if you have it) to send HTTP requests to the server and see what's returned.

Come to think of it. Reading the headers alone (i did that too) will allow you to see if it exists or not.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

i thought file_get_contents went with redirects...it was either that or curl() but i cant find my book at the moment...
Post Reply