title: URL Validation in PHP
body: <p>The topic has been discussed a lot here at StackOverflow but all the answers I managed to explore fail to produce the results I need. I want to check before inserting the URL into database that the value is actually a URL. The default function of PHP FILTER_VALIDATE_URL returns true even if we just provide httpp://exampl</p>
  
  <p>but I need to validate the value only if it is a true domain like example.net, example.com etc.. Let's try an example:</p>
  
  <p>Case 1:</p>
  
  <pre><code>$url = "http://example";
  if(!filter_var($url, FILTER_VALIDATE_URL) === false) {
                  return true;
              }
  </code></pre>
  
  <p>This above returns true but domain isn't valid.</p>
  
  <p>Case 2:</p>
  
  <pre><code>$url = "http://google.com";
  if(!filter_var($url, FILTER_VALIDATE_URL) === false) {
                  return true;
              }
  </code></pre>
  
  <p>Returns true and that's okay.</p>
  
  <p>But any possible solution for case 1? Please help.</p>
  
  <p>P.S.: I used CURL and it works but the response is too slow (more than 5 seconds). Any solid solution will be greatly appreciated.</p>