If "if-modified-since" doesn't work (it often won't) and you have PHP5 then try filemtime() or stat(). Otherwise, this should work:
$compare_file = 'compare.txt';
$url = 'http://www.example.com/page.html';
$url_return = file_get_contents($url);
/**
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$url_return = curl_exec($ch);
curl_close($ch);
**/
if (file_exists($compare_file)) {
$compare_str = file_get_contents($compare_file);
if ($compare_str == $url_return) {
echo 'File has not changed.<br />';
} else {
echo 'File has changed.<br />';
write_compare_file($compare_file, $url_return);
}
} else {
echo 'No storage file to compare; ' .
$compare_file . ' being written.<br />';
write_compare_file($compare_file, $url_return);
}
function write_compare_file($file, $str)
{
$fp = fopen($file, 'w');
fwrite($fp, $str);
fclose($fp);
return true;
}
If that doesn't work then you probably don't have fopen wrappers enabled. In that case, if you have curl enabled, delete the first "file_get_contents()" line and the comment markers. If you don't have either fopen wrappers or curl enabled you'll have to do something else.