PHP stat() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The stat() function returns information about a file.
This function returns 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 links
- [4] or [uid] - User ID of the owner
- [5] or [gid] - Group ID of the owner
- [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 modification time (Unix timestamp)
- [10] or [ctime] - Last inode change time (Unix timestamp)
- [11] or [blksize] - Block size of filesystem IO (if supported)
- [12] or [blocks] - Number of blocks allocated
Syntax
stat(
filename
)
| Parameters | Description |
|---|---|
| filename | Required. Specifies the path of the file. |
Tips and Notes
**Note:** The results returned by this function differ from server to server. This array contains numeric indices, named indices, or both.
**Note:** The results of this function are cached. Use clearstatcache() to clear the cache.
Example
Modification time: ' .$stat['mtime']; echo 'Device number: ' .$stat['dev']; ?>
The code above will output:
Access time: 1141633430
Modification time: 1141298003
Device number: 0
Complete PHP Filesystem Reference Manual