title: Check if file exists on another website
body: <p>I've been trying to develope code that would check if a pdf file exists on another website. For testing purposes, I found a random pdf file online:</p>
  
  <p><a href="http://www.tutorialspoint.com/php/php_tutorial.pdf" rel="nofollow">http://www.tutorialspoint.com/php/php_tutorial.pdf</a></p>
  
  <p>I tried the following code and neither of the two methods worked:</p>
  
  <p>Method 1:</p>
  
  <pre><code>$path1 = 'http://www.tutorialspoint.com/php/php_tutorial.pdf';
  if (file_exists($path1))
  {
    echo "found!";
  }
  else
  {
    echo "not found";
  }
  
  //RESULT: not found
  </code></pre>
  
  <p>Method 2:</p>
  
  <pre><code>function UR_exists($url){
     $headers=get_headers($url);
     return stripos($headers[0],"200 OK")?true:false;
  }
  
  if(UR_exists('http://www.tutorialspoint.com/php/php_tutorial.pdf'))
     echo "This page exists";
  else
     echo "This page does not exist";
  
  //RESULT: This page does not exist
  </code></pre>
  
  <p>The page executes fine in both situations, but the result is always that the file doesn't exist, when I know it exists lol. What am I doing wrong?</p>