|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80855 FILTER_VALIDATE_DOMAIN does not recognize emoji TLDs with FILTER_FLAG_HOSTNAME
Submitted: 2021-03-11 19:54 UTC Modified: 2021-03-11 20:32 UTC
From: vijaycs85 at gmail dot com Assigned:
Status: Not a bug Package: Filter related
PHP Version: 7.4.16 OS: OSX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
14 + 14 = ?
Subscribe to this entry?

 [2021-03-11 19:54 UTC] vijaycs85 at gmail dot com
There are some countries that allow Top Level Domains(TLDs) with emoji and the filter_var does not recognize them.


Test script:
$domain_name = '⚡.kz';
$is_valid = filter_var($domain_name, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);

Expected result:
string(4) "⚡.kz"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-11 20:10 UTC]
-Status: Open +Status: Not a bug
 [2021-03-11 20:10 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at
> Optional flag FILTER_FLAG_HOSTNAME adds ability to specifically validate
> hostnames (they must start with an alphanumeric character and contain only
> alphanumerics or hyphens).

Note that ⚡.kz must be converted to punycode, ie. That would be considered valid with the HOSTNAME flag.
 [2021-03-11 20:22 UTC] vijaycs85 at gmail dot com
>Note that ⚡.kz must be converted to punycode, ie. That would be considered valid with the HOSTNAME flag.

Thanks for your quick reply and clarification.
 [2021-03-11 20:29 UTC] vijaycs85 at gmail dot com
Just for future reference, the below code provides the expected result.

$domain_name = '⚡.kz';
$is_valid = filter_var(idn_to_ascii($domain_name), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);


string(10) ""
 [2021-03-11 20:32 UTC]
Or don't use the HOSTNAME flag.

$domain_name = '⚡.kz';
$is_valid = filter_var($domain_name, FILTER_VALIDATE_DOMAIN);
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 08:05:45 2022 UTC