How to hyperlink a web address or a non web address in php
<p>I have a website were users enters articles and their reference(like wikipedia). The reference which were saved in the database includes both web address and non web addresses.Currently i am hyper linking the script using google's search?q and its working properly.</p>

<pre><code>     echo("&lt;br&gt;&lt;a rel=nofollow  target=_blank href='http://www.google.com/search?q=".urlencode($row['ref'])."' class=art&gt;$row[ref]&lt;/a&gt;");
</code></pre>

<p>i want to know whether its possible to automatically detect my reference as a web address or not .if it is a web address then when users click to the hyperlink it goes directly to that website and if not it should hyperlink to google search.</p>

<p>eg:</p>

<p>if user enters this link as reference.hyper link should be to this web address</p>

<pre><code>      http://www.washingtonpost.com/sports/capitals
      or
      www.washingtonpost.com/sports/capitals
      or
      washingtonpost.com/sports/capitals
</code></pre>

<p>or if the user enters reference as below </p>

<pre><code>     washingtonpost+sports+capitals
</code></pre>

<p>it should go to googles search?q</p>

<p>advance thanks for your help</p>
