Created
September 19, 2012 09:58
-
-
Save CodeNegar/3748796 to your computer and use it in GitHub Desktop.
php: validate url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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