On Mon, 2009-09-21 at 14:42 -0400, Al wrote: > What's the simplest way to test if a link is valid? > > I've got a script that throughly checks the dns, etc. But, I'd also like to > check to see if the user has inputted a valid link to a webpage. > > File_exists() and etc. seem to have a lot of caveats. > > E.g., foo.com/bar/file.txt > > Most things I've looked at are gross overkill. > > Al........ > Several ways that I can think of: * use the file_get_contents() which like you said, could be overkill * shell out to wget to retrieve just the headers for the path. You'd be looking for a 200 return code, which indicates the URI exists. * lastly, you could use fopen() to open the file, and use the return from the fopen() call to indicate a success of failure Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php