function valid_url

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.

Parameters

$url: The URL to verify.

$absolute: Whether the URL is absolute (beginning with a scheme such as "http:").

Return value

TRUE if the URL is in a valid format.

Deprecated

as of Drupal 8.0. Use UrlValidator::isValid() instead.

See also

\Drupal\Component\Utility\UrlValidator::isValid()

Related topics

3 calls to valid_url()
form_validate_url in drupal/core/includes/form.inc
Form element validation handler for #type 'url'.
OpmlFeedAdd::submitForm in drupal/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php
Form submission handler.
UrlTest::testDrupalParseUrl in drupal/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
Tests drupal_parse_url().

File

drupal/core/includes/common.inc, line 797
Common functions that many Drupal modules will need to reference.

Code

function valid_url($url, $absolute = FALSE) {
  return UrlValidator::isValid($url, $absolute);
}