You can validate url using php filter_var() function using following code.

$url = 'http://mywebsite.com';
$result = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);
if ( $result )
{
echo 'Valid URL';
}
else 
{
$output = 'Not A Valid URL';
}