Return to Snippet

Revision: 18205
at September 23, 2009 15:57 by paulgrenwood


Initial Code
if (!preg_match("/^(http|ftp):/", $_POST['url'])) {
   $_POST['url'] = 'http://'.$_POST['url'];
}

Initial URL

                                

Initial Description
Some times you need to accept some url as input but users seldom add http:// to it, this code will add http:// to the URL if it’s not there.

Initial Title
Prepend http to a URL

Initial Tags
http, php, link

Initial Language
PHP