I'm trying to find a best solution to save from performance, memory usage etc. for checking if a file exist on different domain or not. In my case, the file is an XML and the size can be between 10KB up to 10MB.
Which of these would be the best to use? If you have a better approach, I'll be happy to use it instead.
Thanks
CURL
$ch = curl_init("http://www.example.com/hello.xml");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// $retcode > 400 -> not found, $retcode = 200, found.
curl_close($ch);
FOPEN
$url = "http://www.example.com/hello.xml";
if (@fopen($url, "r")) {
echo "File Exists";
} else {
echo "Can't Connect to File";
}