jquery getting url parameters & value

Hi guys , here I am going to share a simple php function which is taken care of our fixing url/links problem.

This function will add http or https in front of urls which doesnt hav.

Here is the PHP code

function fix_url($url) {
 if (substr($url, 0, 7) == 'http://') { return $url; }
 if (substr($url, 0, 8) == 'https://') { return $url; }
 return 'http://'. $url;
 }

Usage

 <?php echo fix_url('www.google.com'); ?> 

Output

 http://www.google.com 

Please don’t forget to share and subscribe to latest updates of the blog. Comments and feedbacks are always welcome!

Thanks!

Related Posts