How to check a url is valid
am 15.11.2005 00:17:04 von unknownPost removed (X-No-Archive: yes)
Post removed (X-No-Archive: yes)
Krustov wrote:
> Any recommended methods I could use to check the url is valid before
> accepting it ? .
One thing you could do is resolve the domain name they type in.
Tools like dig or nslookup can do this.
Here's a PHP package (GPL license) that says it does this, but I haven't
used it:
http://www.hotscripts.com/Detailed/47915.html
No doubt there are other similar PHP functions available out there.
Regards,
Bill K.
Krustov wrote:
> Any recommended methods I could use to check the url is valid before
> accepting it ? .
if ( @open($url, 'r') === FALSE )
echo "URL Fake\n";
else
echo "Go ahead!\n";
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Post removed (X-No-Archive: yes)
Post removed (X-No-Archive: yes)
Post removed (X-No-Archive: yes)
Krustov wrote:
> @open didnt work for me - but fopen appears to work fine .
That's the one. My mistake -- should have tested it really.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Post removed (X-No-Archive: yes)
Toby Inkster wrote:
> Krustov wrote:
>
>> @open didnt work for me - but fopen appears to work fine .
>
> That's the one. My mistake -- should have tested it really.
I still advise using the @-sign though:
@fopen()
the @ suppresses PHP's error-printing (assuming you have it switched on at
all), so the visitors won't see any ugly message if things go wrong --
just your own pretty message.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Post removed (X-No-Archive: yes)