/* * It checks if string is an URL. * * @param string $string * @param string $flags * Posibility flags: * HOST_REQUIRED - URL with a host (example: http://url.com), * PATH_REQUIRED - URL with path after a name of domain (example: http://url.com/Home) * QUERY_REQUIRED - URL with a Query String (example: http://url.com/index.php?x=y). * @return boolean */ function isURL($string, $flags='QUERY_REQUIRED') { if($flags=='HOST_REQUIRED') { return (bool)preg_match("/^(http|https|ftp|file):\/\/(www)?[a-zA-Z0-9_\/.\-]+\.[a-zA-Z0-9]+(\/)?$/i", $string); } else if($flags=='PATH_REQUIRED') { return (bool)preg_match("/^(http|https|ftp|file):\/\/(www)?[a-zA-Z0-9_\/.\-]+\.[a-zA-Z0-9]+\/[a-zA-Z0-9_.\-#]*$/i", $string); } else if($flags=='QUERY_REQUIRED') { return (bool)preg_match("/^(http|https|ftp|file):\/\/(www)?[a-zA-Z0-9_\/.\-]+\.[a-zA-Z0-9]+\/[a-zA-Z0-9_.\-#]*\?[a-zA-Z0-9_.,\-?#=&]+$/i", $string); }
W jaki sposób pozbyć się możliwości napisania 2 kropek obok siebie? Prosiłbym również o spr. czy nie ma tu innych błędów.
