webpage link validation
am 21.09.2009 20:42:44 von 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
Re: webpage link validation
am 21.09.2009 20:52:17 von 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
RE: webpage link validation
am 21.09.2009 21:11:39 von Andrea Giammarchi
--_73f00193-9bd9-4254-8891-dead1dae0215_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
=20
> Several ways that I can think of:
>=20
> * use the file_get_contents() which like you said=2C could be
> overkill
> * shell out to wget to retrieve just the headers for the path.
> You'd be looking for a 200 return code=2C which indicates the URI
> exists.
> * lastly=2C you could use fopen() to open the file=2C and use the
> return from the fopen() call to indicate a success of failure
>=20
> Thanks=2C
> Ash
you forgot probably the best one=2C an HEAD call via curl library ( http://=
uk3.php.net/curl ) if present
Regards
____________________________________________________________ _____
Drag n=92 drop=97Get easy photo sharing with Windows Live=99 Photos.
http://www.microsoft.com/windows/windowslive/products/photos .aspx=
--_73f00193-9bd9-4254-8891-dead1dae0215_--