PHP cheapest way how to check if remote image exist
<p>I want to check if a remote image exist.
Currently using CURL and based on its response to i can determine if the file exist. 
However, this takes a fare bit amount of time depending on the image file size also. </p>

<p>Is there a safest and cheapest way of doing a check without doing it offline or using cache?</p>

<pre><code>$ch = curl_init();
        // set URL and other appropriate options
        /*--Note: if in sabre proxy, please activate the last 4 lines--*/
        $options = array(   CURLOPT_URL =&gt; $img,
                            CURLOPT_HEADER =&gt; false,  // get the header
                            CURLOPT_NOBODY =&gt; true,  // body not required
                            CURLOPT_RETURNTRANSFER =&gt; false,  // get response as a string from curl_exec, not echo it
                            CURLOPT_FRESH_CONNECT =&gt; false,  // don't use a cached version of the url
                            CURLOPT_FAILONERROR =&gt; true,
                            CURLOPT_TIMEOUT =&gt; 5
                        );


        curl_setopt_array($ch, $options);

        if(!curl_exec($ch)) { return FALSE; } 

        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        curl_close($ch);

        return ($httpcode&lt;400); 
</code></pre>
