PHP fstat() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The fstat() function returns information about an open 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
fstat(file)
| Parameters | Description |
|---|---|
| file | Required. Specifies the open file to check. |
Tips and Notes
**Note:** The results returned by this function differ from server to server. This array contains numeric indices, named indices, or both.
**Tip:** fstat() is roughly similar to stat(). The only difference is that with fstat() the file must already be open.
Example
The code above will output:
Array
(
[0] => 0
[1] => 0
[2] => 33206
[3] => 1
[4] => 0
[5] => 0
[6] => 0
[7] => 92
[8] => 1141633430
[9] => 1141298003
[10] => 1138609592
[11] => -1
[12] => -1
[dev] => 0
[ino] => 0
[mode] => 33206
[nlink] => 1
[uid] => 0
[gid] => 0
[rdev] => 0
[size] => 92
[atime] => 1141633430
[mtime] => 1141298003
[ctime] => 1138609592
[blksize] => -1
[blocks] => -1
)
Complete PHP Filesystem Reference Manual