/**
* Returns true if the string passed may be a URL ie. it starts with protocol://.
*
* @param string $url
* @return bool
*/
function isValidUrl(string $url)
{
return $url && preg_match('~^(([[:alpha:]][[:alnum:]+.-]*)?:)?//(.*)$~D', $url, $matches) !== 0
&& strlen($matches[3]) > 0
&& !preg_match('/^(javascript:|vbscript:|data:)/i', $matches[1]);
}