note 98036 added to function.filter-var
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 21 May 2010 18:41:39 +0000 |
| Subject: | note 98036 added to function.filter-var | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169507@lists.php.net to get a copy of this message | ||
<?php
if (filter_var('http://www.....com/abcd',
FILTER_VALIDATE_URL) != FALSE)
{
echo "valid url";
}
else
{
echo "invalid url";
}
?>
Why is this valid? The host is not valid...
filter_var('http://www.abc_def.com/abcd',
FILTER_VALIDATE_URL)
filter_var('http://www.abc#$%^&def.com/abcd',
FILTER_VALIDATE_URL)
Also valid... Why? Because it's invalid... Do I something wrong?
I'm searching the best way to validate the host. Using regex is hard because of the new
accepted i18n chars in domainname aka host. And using parse_url is just a nice explode, it does not
check the parts for validity.
----
Server IP: 91.199.167.223
Probable Submitter: 94.214.169.162
----
Manual Page -- http://www.php.net/manual/en/function.filter-var.php
Edit -- https://master.php.net/note/edit/98036
Del: integrated -- https://master.php.net/note/delete/98036/integrated
Del: useless -- https://master.php.net/note/delete/98036/useless
Del: bad code -- https://master.php.net/note/delete/98036/bad+code
Del: spam -- https://master.php.net/note/delete/98036/spam
Del: non-english -- https://master.php.net/note/delete/98036/non-english
Del: in docs -- https://master.php.net/note/delete/98036/in+docs
Del: other reasons-- https://master.php.net/note/delete/98036
Reject -- https://master.php.net/note/reject/98036
Search -- https://master.php.net/manage/user-notes.php