PHP fstat() Function

Definition and Usage

The fstat() function returns information about the open file.

Syntax

fstat(file)
Parameter Description
pipe Required. Specifies the open file to be checked.

Description

Get statistics of the file opened by the file pointer handle.

The array returned by this function contains the statistics of the file, including the following elements:

Numeric index Associated key name (since PHP 4.0.6) Description
0 dev Device name
1 ino Number
2 mode inode protection mode
3 nlink Number of connections
4 uid User ID of the owner
5 gid Group ID of the owner
6 rdev Device type, if it is an inode device
7 size Number of bytes in file size
8 atime Last visit time (Unix timestamp)
9 mtime Last modification time (Unix timestamp)
10 ctime Last change time (Unix timestamp)
11 blksize Block size of file system IO
12 blocks Number of blocks occupied

Tips and Comments

Tip:This function is similar to stat() The function is similar, but it acts on an open file pointer instead of a file name.

Example

<?php
$file = fopen("test.txt","r");
print_r(fstat($file));
fclose($file);
?>

Output similar to:

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
)