Skip to content

Instantly share code, notes, and snippets.

@ReekenX
Created March 19, 2014 05:02
Show Gist options
  • Select an option

  • Save ReekenX/9635679 to your computer and use it in GitHub Desktop.

Select an option

Save ReekenX/9635679 to your computer and use it in GitHub Desktop.
Validate URL
<?php
$url = "http://example.org/";
if (preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) {
echo "Your url is ok.";
} else {
echo "Wrong url.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment