Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link validation

Status
Not open for further replies.

cmhunt

Programmer
Joined
Apr 17, 2001
Messages
119
Location
GB
I would like create a link depending upon whether the link is working or not. Is there anyway of testing whether a link produces a "Page Cannot be displayed" so I can substitute this for another link before sending to the client?

Any help is gratefully appreciated.

Thanks

Chris
 
You could use curl to submit the page and return the output into a variable. Then parse this looking for the errors you want to parse out.

I imagine you'll need to discover several errors and such, and then figure out the most unique text to look for so that you're not fooled if someone has similar text pasted into their document.


-Rob
 
It may not be necessary to use curl.

If your version of PHP supports using a URL in the fopen command, you could read the content returned and search for a particular string. (
Also, if you have fsockopen available to you, you could sent the HTTP necessary to try to retrieve the page -- all you need it the HTTP return status code, which appears early in the return, so you would not have to read much back before closing the socket. (


Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top