Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

fstat()

Example

Provide details about the open file back to me:erroneous

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

Definition and Usage

The information about an open file is returned by the fstat() function.

Note: This function’s output will vary depending on the server. Either the name index, the number index, or both may be present in the array.

Advice: This function is comparable to stat(), but it requires that the file be open in order to work.

Syntax

fstat(file)

Parameter Values

 

Parameter

Description

file

Essential. indicates which open file to examine.

Technical Details

Return Value:

An array containing the open file’s details:
Device number: [0] or [dev];

[1] or [ino] – Inode count
[2] or [mode] – Mode of inode protection
[3] or [nlink] – Link count 
[4] or [uid] – The owner’s user ID 
[5] or [gid] – Owner’s group ID 
[6] or [rdev] Type of inode device: 
[7] or [size] – Byte size: 
[8] or [atime] – Last access 
[9] or [mtime] (as a Unix timestamp) – Last edited 
[10] or [ctime] (as a Unix timestamp) – Last inode modification 
[11] or [blksize] (as a Unix timestamp) – The filesystem’s IO block size (if supported)
[12] or [units] – The quantity of blocks allotted

PHP Version:

4.0+