RE: [PHP] webpage link validation

2009-09-21 Thread Andrea Giammarchi

 
> 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

you forgot probably the best one, an HEAD call via curl library ( 
http://uk3.php.net/curl ) if present

Regards

_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Re: [PHP] webpage link validation

2009-09-21 Thread Ashley Sheridan
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



[PHP] webpage link validation

2009-09-21 Thread Al

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php