Skip to content

Instantly share code, notes, and snippets.

@CodeNegar
Created September 19, 2012 09:58
Show Gist options
  • Save CodeNegar/3748796 to your computer and use it in GitHub Desktop.
Save CodeNegar/3748796 to your computer and use it in GitHub Desktop.
php: validate url
<?php
public static function validate_url($str)
{
if (empty($str))
return true;
if (strpos($str, "http") === false) {
return false;
} else {
return (!preg_match('/^(http|https|ftp)); //\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+)); //?(\d+)?\/?/i', $str)) ? FALSE : TRUE;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment