Re: Validate package - url/uri problems
| From: | Christian Weiske | Date: | Mon, 28 Jan 2008 20:19:33 +0000 |
| Subject: | Re: Validate package - url/uri problems | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-28488@lists.php.net to get a copy of this message | ||
Hello Mike,
> I am using the pear Validate package in order to validate any urls
> submitted through my website, however, it doesn't seem to be behaving
> the way it should - all urls without 'http://' at the
> start will
> validate false
This is normal. A valid URI needs to have a schema. The method does not
complete or fix URLs.
> and even more annoyingly, all urls that do start with
> 'http://' validate true!
> This means 'www.example.com' is false and
> 'http://example.blobbyblobexecutescript.hopalong' is
> true! Surely
> this can't be right? What am I dong wrong?
You can pass an option as second parameter:
> Validate::uri($uri, array('domain_check' => true));
This will check if the domain exists.
I'm in line with you that at least the TLD should and could be checked
for integrity without connecting to any server.
> The line of code I am using is:
> if (!Validate::uri($url)) {
> echo'url invalid';
> }
That's correct.
--
Regards/Mit freundlichen Grüßen
Christian Weiske
Attachment: [application/pgp-signature] signature.asc
Attachment: [application/pgp-signature] signature.asc