Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kevin Dunglas:
PHP 7: Introducing a domain name validator and making the URL validator stricter
Nov 28, 2014 @ 09:45:19

In his latest post Kevin Dunglas has released information about a patch for URL filtering that aims to bring more validation and functionality to the pre-existing filter_var functionality.

Until now, there was no PHP’s filter validating that a given a string is a valid domain name (or hostname). Worst, FILTER_VALIDATE_URL was not fully enforcing domain name validity (this is mandatory for schemes such as http and https) and was allowing invalid URLs. FILTER_VALIDATE_URL was also lacking IPv6 host support.

His patch introduces support for domain validation rules more strict to what the RFC defines and includes IPv6 support. There's a few code examples included in the post showing the new support. He points out that there's still some things that aren't supported yet, like internationalized domains, but there's future plans for it.

tagged: php7, filtervar, filter, url, domain, patch, support

Link: http://dunglas.fr/2014/11/php-7-introducing-a-domain-name-validator-and-making-the-url-validator-stricter/