Home Tutorial Php Phpfiles feof() Function in php

 
 

feof() Function in php
Posted on: September 21, 2009 at 12:00 AM
The example of feof() Function in the PHP programming language.

Examples of the feof() function in PHP

Syntax on feof() function in PHP

bool feof ( $file_pointer )

It is used for checking the end of file of  the  file pointer returned by fopen() and fsockopen()

It is used with loops to show the content of the file line by line by the functions fgets()

It returns false if the file pointer has not reached to the end of file. So the loop will continue.

It returns true if the file pointer  is reached to the end and then the loop will terminate

Code for feof() function in PHP

<?php

$file1=fopen("c:/rose1/ram.txt","r");

do

{

$line=fgets($file1);

echo $line;

echo "<br/>";

}

while(!feof($file1))

?>

Output

welcome to roseindia
welcome to roseindia
welcome to roseindia
welcome to roseindia
welcome to roseindia
welcome to roseindia

 

Related Tags for feof() Function in php:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.