<?php
$url = "http://www.google.com";
echo preg_match("/^http(s?):\/\/(\w+\.)?\w+\-?\.\w{2,6}(.*)?$/", $url) ?
"<a href = '$url'>$url</a>" : $url;
PD9waHAKJHVybCA9ICJodHRwOi8vd3d3Lmdvb2dsZS5jb20iOwplY2hvIHByZWdfbWF0Y2goIi9eaHR0cChzPyk6XC9cLyhcdytcLik/XHcrXC0/XC5cd3syLDZ9KC4qKT8kLyIsICR1cmwpID8gIjxhIGhyZWYgPSAnJHVybCc+JHVybDwvYT4iIDogJHVybDs=