Drupal 7 provide us a valid_url() function to check the Url validation.In drupal 7 we can call it directly because it was written in the module file.But in D8 we can't.
In D8 we have to use UrlHelper class and the help of this class we can use this function.
In D8 valid_url() is converted into isValid(), so for using this function,
In D8 we have to use UrlHelper class and the help of this class we can use this function.
In D8 valid_url() is converted into isValid(), so for using this function,
- First, include class namespace
use Drupal\Component\Utility\UrlHelper; - then use this function, No need to create the object because it is a static function so we can call it by its class name
UrlHelper::isValid($url, $absolute = FALSE);
Parameters : -
$url : -The URL to verify
bool $absolute: Whether the URL is absolute
Thanks for this. Appreciated
ReplyDelete