note 107450 added to function.filter-var
| From: | ole dot aass at yahoo dot no | Date: | Fri, 10 Feb 2012 02:42:00 +0000 |
| Subject: | note 107450 added to function.filter-var | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186044@lists.php.net to get a copy of this message | ||
Like mentioned by php at maisqi dot com, this function does not support IDN, and instead for
reinventing the wheel we can use the idn_to_ascii function in the intl module.
Example:
<?php
function validateUrl($url)
{
$idn = idn_to_ascii($url);
return filter_var($idn, FILTER_VALIDATE_URL);
}
?>
How it works, is that idn_to_ascii converts the multi-byte url to a punycode ascii string. Below is
the example in these docs
<?php
echo idn_to_ascii('täst.de');
?>
Returns: xn--tst-qla.de
This is the actual url stored in the DNS
That string can also be reversed by using idn_to_utf8()
----
Server IP: 69.147.83.197
Probable Submitter: 46.9.207.119
----
Manual Page -- http://www.php.net/manual/en/function.filter-var.php
Edit -- https://master.php.net/note/edit/107450
Del: integrated -- https://master.php.net/note/delete/107450/integrated
Del: useless -- https://master.php.net/note/delete/107450/useless
Del: bad code -- https://master.php.net/note/delete/107450/bad+code
Del: spam -- https://master.php.net/note/delete/107450/spam
Del: non-english -- https://master.php.net/note/delete/107450/non-english
Del: in docs -- https://master.php.net/note/delete/107450/in+docs
Del: other reasons-- https://master.php.net/note/delete/107450
Reject -- https://master.php.net/note/reject/107450
Search -- https://master.php.net/manage/user-notes.php