How can predefined constants be utilized in PHP to access file modification information?
Predefined constants in PHP, such as `filemtime()` and `filectime()`, can be utilized to access file modification information. These constants allow you to retrieve the timestamp of when a file was last modified or when its inode was last changed. By using these predefined constants, you can easily retrieve and display file modification information in your PHP code.
$filename = 'example.txt';
// Get the timestamp when the file was last modified
$lastModified = filemtime($filename);
// Get the timestamp when the file's inode was last changed
$lastInodeChange = filectime($filename);
echo "File last modified: " . date('Y-m-d H:i:s', $lastModified) . "<br>";
echo "File last inode change: " . date('Y-m-d H:i:s', $lastInodeChange);
Related Questions
- Are there any PHP functions or libraries that can simplify the process of reading and organizing log entries from a text file?
- How can PHP be used to update existing database entries based on specific criteria, such as matching keywords from a text file?
- In the context of PHP forums, what are the potential risks of allowing users to input custom IDs for data retrieval?