This function will check the the given url has prefixed http or https. if it is not it will prefix http on the given url.
function prefixHttpOnUrl($url = ''){
    if ($url == ''){
        return '';
     }
    if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://'){
        $url = 'http://'.$url;
    }
   
    return $url;
}
prefixHttpOnUrl("www.phpqa.blogspot.com")  will return http://www.phpqa.blogspot.com
prefixHttpOnUrl("phpqa.blogspot.com")  will return http://phpqa.blogspot.com
prefixHttpOnUrl("http://phpqa.blogspot.com")  will return http://phpqa.blogspot.com
enjoy PHP'ing
          [Thursday, April 23, 2009
 | 
0
comments
]
    
Popular Posts
- Help with codeignitor
 - Contact Me
 - Creating Google map and adding markers ans polyline on it
 - PHP Question and answers
 - Mysql Questions
 - Add/Remove text control using javascript
 - function to check whether the year given is a leap year or not
 - Random password generation :using ajax and jquery
 - Css
 - Creating Custom Module in VtigerCRM
 

0 comments
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.