Skip to content

Instantly share code, notes, and snippets.

@symm
Created August 4, 2012 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symm/3260113 to your computer and use it in GitHub Desktop.
Save symm/3260113 to your computer and use it in GitHub Desktop.
PHP url validation bug
<?php
/*
* FILTER_VALIDATE_URL Validates value as URL (according to » http://www.faqs.org/rfcs/rfc2396)
* http://php.net/manual/en/filter.filters.validate.php
*/
$check = filter_var('http://google.com/', FILTER_VALIDATE_URL);
var_dump($check);
// $check = string(18) "http://google.com/"
// Trailing dot in domain (valid) is incorrectly rejected
$check = filter_var('http://google.com./', FILTER_VALIDATE_URL);
var_dump($check);
// $check = bool(false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment