note 107450 deleted from function.filter-var by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 21:14:23 +0000 |
| Subject: | note 107450 deleted from function.filter-var by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187858@lists.php.net to get a copy of this message | ||
Note Submitter: ole dot aass at yahoo dot no
----
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()