English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The stat() function can return information about the file.
array stat ( string $filename )
This function can collect statistical information about the file named filename. If the filename is a symbolic link, the statistical information comes from the file itself, not the symbolic link. The lstat() function is the same as the stat() function, but it can be based on the symbolic link status.
<?php $stat = stat("/PhpProject/sample.txt"); //Get file status echo "Access time: " . $stat["atime"]; //Print file access time, which is the same as calling fileatime() echo "\nModification time: " . $stat["mtime"]; //Print file modification time, which is the same as calling filemtime() echo "\nDevice number: " . $stat["dev"]; // Print device number ?>
Output Result
Access time: 1590217956 Modification time: 1591617832 Device number: 1245376677
<?php $stat = stat("/PhpProject/sample.txt"); if(!$stat) { echo "stat() call failed..."; } else { $atime = $stat["atime"] + 604800; if(!touch("/PhpProject1/sampl2.txt, time(), $atime)) { echo "failed to touch file..."; } else { echo "touch() returned success..."; } ?>
Output Result
touch() returned success...