Home  |  Linux  | Mysql  | PHP  | XML
Date:Fri Feb 10 02:42:00 2012
Subject:note 107450 added to function.filter-var
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


Navigate in group php.notes at sever news.php.net
Previous Next





  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants