PHP fstat () function
Definition and Usage
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] - the number of connections
- [4] or [uid] - owner user ID
- [5] or [gid] - owner group ID
- [6] or [rdev] - inode device type
- [7] or [size] - Number of bytes of the file size
- [8] or [atime] - time of last access (Unix timestamp)
- [9] or [mtime] - last modified (Unix timestamp)
- [10] or [ctime] - Last inode change time (Unix timestamp)
- [11] or [blksize] - IO file system block size (if supported)
- [12] or [blocks] - The number of occupied blocks
grammar
fstat(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的打开文件。 |
Tips and Notes
Note: The results from the server to the result returned by this function is not the same server.This array contains a numerical index, including the name index, or both.
Tip: fstat () function and stat () function substantially similar.The only difference is, fstat () function is in use, the file must be open.
Examples
<?php
$file = fopen("test.txt","r");
print_r(fstat($file));
fclose($file);
?>
$file = fopen("test.txt","r");
print_r(fstat($file));
fclose($file);
?>
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
)
(
[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