What is the function in PHP that can be used to check when a file was last modified?
To check when a file was last modified in PHP, you can use the `filemtime()` function. This function returns the last modified time of the file in Unix timestamp format, which can be converted to a human-readable format using the `date()` function. By using `filemtime()`, you can easily retrieve the last modified time of a file and display it to the user.
$filename = 'example.txt';
if (file_exists($filename)) {
$lastModified = filemtime($filename);
echo "The file was last modified on " . date('Y-m-d H:i:s', $lastModified);
} else {
echo "File does not exist.";
}
Related questions
-
PHP guestbook separate folder
-
SQL injection cross-site scripting (XSS) data validation
-
mysql_real_escape_string SQL injections PHP