title: Check if a string contains nothing but an URL in PHP
body: <p>I am wondering if this is a proper way to check, if a string contains nothing but an URL:</p>
  
  <pre><code>if (stripos($string, 'http') == 0 &amp;&amp; !preg_match('/\s/',$string)) {
    do_something();
  }
  </code></pre>
  
  <p>stripos() checks if the string starts with "http"<br>
  preg_match() checks if the string contains spaces</p>
  
  <p>If not so, I assume that the string is nothing but an URL - but is that assumption valid? Are there better ways to achieve this?</p>