PHP link href formatter


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $url = "blahblah.com";
  3. // to clarify, this shouldn't be === false, but rather !== 0
  4. if (0 !== strpos($url, 'http://') && 0 !== strpos($url, 'https://')) {
  5. $url = "http://{$url}";
  6. }
  7. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.