The stat() function returns information about a file.
This function will return an array containing the following elements:
[0] or [dev] - device number
[1] or [ino] - inode number
[2] or [mode] - inode protection mode
[3] or [nlink] - number of connections
[4] or [uid] - The user ID of the owner
[5] or [gid] – The owner’s group ID
[6] or [rdev] - inode device type
[7] or [size] - file size in bytes
[8] or [atime] - last access time (Unix timestamp)
[9] or [mtime] - Last modified time (Unix timestamp)
[10] or [ctime] - Last inode change time (Unix timestamp)
[11] or [blksize] - Block size for file system IO (if supported)
[12] or [blocks] - number of occupied blocks
stat( filename )
parameter | describe |
---|---|
filename | Required. Specifies the path to the file. |
Note: The results returned from this function are not the same as server-to-server results. This array contains numeric indexes, name indexes, or both.
Note: The results of this function will be cached. Please use clearstatcache() to clear the cache.
<?php$stat = stat('test.txt');echo 'Acces time: ' .$stat['atime'];echo '<br />Modification time: ' .$stat['mtime'];echo '<br />Device number: ' .$stat['dev'];?>
The above code will output:
Access time: 1141633430Modification time: 1141298003Device number: 0