The stat() function returns information about a file.
PHP stat() Function has the following syntax.
stat(filename)
Parameter | Is Required | Description |
---|---|---|
filename | Required. | Path to the file |
This function returns an array with the following elements:
The result of this function are cached. Use clearstatcache() to clear the cache.
<?php
$stat = stat('test.txt');
echo 'Acces time: ' .$stat['atime'];
echo '\nModification time: ' .$stat['mtime'];
echo '\nDevice number: ' .$stat['dev'];
?>
<?php
$stat = stat('test.txt');
echo 'Acces time: ' .$stat['atime'];
echo '<br />Modification time: ' .$stat['mtime'];
echo '<br />Device number: ' .$stat['dev'];
?>
The code above generates the following result.