How do I check if a URL is valid?

I have a form, one field is for the user to enter a URL. Is there a way with PHP to check if the URL is a valid one? So I can show an error if it is not, or accept it if it’s OK.

You want to use [fphp]filter_var[/fphp] with the type/flag of FILTER_VALIDATE_URL

OK, I have it working now.