FILTER_VALIDATE_URL
过滤器在验证非 ASCII 网址时似乎有一些问题:
The FILTER_VALIDATE_URL
filter seems to have some trouble validating non-ASCII URLs:
var_dump(filter_var('http://pt.wikipedia.org/wiki/', FILTER_VALIDATE_URL)); // http://pt.wikipedia.org/wiki/
var_dump(filter_var('http://pt.wikipedia.org/wiki/Guimarães', FILTER_VALIDATE_URL)); // false
为什么最后一个 URL 没有正确验证?可能的解决方法是什么?运行 PHP 5.3.0.
Why isn't the last URL correctly validated? And what are the possible workarounds? Running PHP 5.3.0.
我还想知道在哪里可以找到 FILTER_VALIDATE_URL
验证过滤器的源代码.
I'd also like to know where I can find the source code of the FILTER_VALIDATE_URL
validation filter.
解析从这里开始:
http://svn.php.net/viewvc/php/php-src/trunk/ext/filter/logical_filters.c?view=markup
实际上是在/trunk/ext/standard/url.c 中完成的
and is actually done in /trunk/ext/standard/url.c
乍一看,我看不到任何有意拒绝非 ASCII 字符的内容,因此可能只是缺少 unicode 支持.PHP 不擅长处理任何地方的非 ASCII 字符.:(
At a first glance I can't see anything that purposely rejects non-ASCII characters, so it's probably just lack of unicode support. PHP is not good in handling non-ASCII characters anywhere. :(
这篇关于PHP filter_var() - FILTER_VALIDATE_URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!