Return to Snippet

Revision: 43290
at March 21, 2011 03:50 by vonlof


Initial Code
// takes a url and appends http to it if http is not present
   function check_http($link){
		$findme   = 'http';
		$pos = strpos($link, $findme);					
		// Note our use of ===.  Simply == would not work as expected  because the position of 'a' was the 0th (first) character.
		if ($pos === false) {
			//echo "The string '$findme' was not found in the string '$mystring'";
			$full_link = "http://".$link;
			
		} else {
			//echo "The string '$findme' was found in the string '$mystring' and exists at position $pos";
			$full_link = $link;
		}
   return $full_link;
   }

Initial URL

                                

Initial Description
takes a url and appends http to it if http is not present

Initial Title
Check url for http

Initial Tags
url, http, link

Initial Language
PHP