Here is my function:
function is_url($url) {
return (preg_match('#^(https?):\/\/#i', $url) && (filter_var($url, FILTER_VALIDATE_URL) !== FALSE));
}
And here is a nice url that it validates as true:
http://blah.com"onclick="alert(document.cookie)
Imagine if that goes into <a href="<?php echo $url; ?>">
Are there any better URL validators with regex? Or is the URL I am testing with actually a valid URL (in which case I would need an XSS clean up function)?