Sanitize URLs With Ease
23 Oct 2013, Posted by inWhen working with URLs, always make sure they are properly formed and don’t contain any invalid or dangerous characters. The esc_url() function lets you do just that.
$my_url = 'http://mypage.com/?awesome=true';
$url = esc_url( $my_url );
Be sure to check out all of the other escape functions. You can find a list of them at the bottom of the page that I linked to in the related section.