PHP Curl get server response
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/408405/easy-way-to-test-a-url-for-404-in-php">Easy way to test a URL for 404 in PHP?</a>  </p>
</blockquote>



<p>I am using curl to download a sequence of pdfs from the backend in PHP. I do not know when the sequence ends like 1.pdf, 2.pdf......etc.</p>

<p>Below is the code I am using to download pdf:</p>

<pre><code>$url  = 'http://&lt;ip&gt;.pdf';
    $path = "C:\\test.pdf";

    $fp = fopen($path, 'w');

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FILE, $fp);

    $data = curl_exec($ch);

    fclose($fp);
</code></pre>

<p>But how do I determine that that pdf do not exists in the backend? Does curl returns any response when file not found?</p>

<p>Thanks In Advance</p>
