We now have a youtube channel. Subscribe!

PHP | fstat() Function

PHP fstat() Function


Hello folks welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP fstat() Function.

The built-in PHP fstat() function returns an information about the open file.

Syntax

Following below is the syntax to use this function -

array fstat ( resource $handle )


This PHP function can gather the statistics of the file opened by the file pointer handle. This function is similar to the built-in PHP stat() function except for the fact that it can operate on an open file pointer instead of a filename.

Return Value

This PHP function returns an information about the open file on success or false on failure.

Example

Try out the below example -

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

Output

When the above code is executed, it will produce the following result -

Array
(
    [0] => 1245376677
    [1] => 12666373952223775
    [2] => 33206
    [3] => 1
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 49
    [8] => 1590217956
    [9] => 1590994836
    [10] => 1590217956
    [11] => -1
    [12] => -1
    [dev] => 1245376677
    [ino] => 12666373952223775
    [mode] => 33206
    [nlink] => 1
    [uid] => 0
    [gid] => 0
    [rdev] => 0
    [size] => 49
    [atime] => 1590217956
    [mtime] => 1590994836
    [ctime] => 1590217956
    [blksize] => -1
    [blocks] => -1
)


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP ftell() Function.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain