How to use Filesystem fgets in PHP

In this article I am going to explain about fgets function in PHP.
  • 1087

PHP fgets() function

The filesystem fgets function is used to returns a line from an open file.

Syntax of fgets function

fgets(filename, length)

Parameters in fgets function

It have two parameter:

Parameter Description
file It specifies the open file to check.
length It specifies the no of byte to read.

Example of filesystem fgets function

<html>

<body>
 

<?php

$handle = @fopen("C:\wamp\www\Dinesh\PhpIntro.txt", "r");

if ($handle) {

    while (!feof($handle)) {

        $buffer = fgets($handle, 1024);

        echo $buffer;

    }

    fclose($handle);

}

?>
 

</body>

</html>


Output:

fgets function.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.