Re: Php filter validate url

From: Date: Sun, 26 Jun 2011 21:44:23 +0000
Subject: Re: Php filter validate url
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-313731@lists.php.net to get a copy of this message
On 06/26/2011 12:31 PM, Adam Tong wrote: > Hi, > > I wanted tu use php filters for validation to avoid regular expresions. > Is it possible that FILTER_VALIDATE_URL only checks if the string has > http:// and do not check for the format domain.something? > ---- > $url = 'http://wwwtestcom'; > $url = filter_var($url,FILTER_VALIDATE_URL); > echo $url; > ----- > > Or I am doing something wrong > > Thank you Unless I'm totally misunderstanding what you want (validate that a string starts with http://) try: if(strpos($url, 'http://') === 0) { //starts with http:// } esle { // does not start with http:// } -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#313731) next »