Verifies the syntax of the given URL.
This function should only be used on actual URLs. It should not be used for Drupal menu paths, which can contain arbitrary characters. Valid values per RFC 3986.
$url: The URL to verify.
$absolute: Whether the URL is absolute (beginning with a scheme such as "http:").
TRUE if the URL is in a valid format.
as of Drupal 8.0. Use UrlValidator::isValid() instead.
\Drupal\Component\Utility\UrlValidator::isValid()
function valid_url($url, $absolute = FALSE) {
return UrlValidator::isValid($url, $absolute);
}