Url validation doesnt work, need a way to validate urls in php
<p>I have got this way to validate urls:</p>

<pre><code>if(!filter_var($url_validity_check, FILTER_VALIDATE_URL) || !preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&amp;@#\/%?=~_|!:,.;]*[-a-z0-9+&amp;@#\/%=~_|]/i", $url_validity_check) )
</code></pre>

<p>{</p>

<p>But it proved useless with some urls..whats the best way to validate a url? is it by sending a request with curl and expect a response code that isnt 404? or check it by ip to see what ip it gets? is there a better and more secure way?</p>

<p>I also have got this code:</p>

<pre><code>$http = curl_init($url);
curl_setopt($http, CURLOPT_MAXREDIRS, 4);
curl_setopt($http, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($http);

$http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
curl_close($http);
echo $http_status;
</code></pre>

<p>But it returns 0.</p>

<pre><code>**UPDATE:**
</code></pre>

<p>I use this regular expression:</p>

<pre><code>#((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\&lt;|$|\.\s)#ie
</code></pre>

<p>Is it good enough, or is there anything better</p>
