How can PHP be used to check if a file has been updated or modified on the server?
To check if a file has been updated or modified on the server using PHP, you can compare the file's last modification time with a previously stored timestamp. If the last modification time is newer than the stored timestamp, then the file has been updated.
$filename = 'example.txt';
$storedTimestamp = filemtime($filename); // Get the last modification time of the file
// Check if the file has been updated
if (filemtime($filename) > $storedTimestamp) {
echo 'File has been updated!';
} else {
echo 'File has not been updated.';
}