faqts : Computers : Programming : Languages : PHP : kms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 19 people (11%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

How Can I check the URL syntax for validity?

Aug 16th, 2004 08:32
Ayse Geertsma, Den Gunn,


There is a difference between valid URL’s and existing URL’s. To check
if a URL is valid, you should dig into this:
http://www.netspace.org/users/dwb/url-guide.html
And then look into “Regular Expression Functions”
(http://www.php.net/preg_match) or write a simple parser. If it’s about
an existing URL you should try and catch the content. There might be
some complications but you should look at:
http://www.php.net/manual/en/function.fsockopen.php
or
http://www.php.net/manual/en/ref.curl.php
or
http://www.php.net/manual/en/function.file-get-contents.php