Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function feof()


previous

Advertisements

Syntax

bool feof ( resource $handle );

Definition and Usage

Tests for end-of-file on a file pointer.

WARNING: If passed file pointer is not valid you may get an infinite loop, because EOF fails to return TRUE.

Paramters

ParameterDescription
handleThe file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).

Return Value

Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.

Example

Following is the usage of this function:

<?php
if ($f = fopen('myfile.txt', 'r')) do {
    $line = fgets($f);
    echo "$line";
    // do any stuff here...
} while (!feof($f));
fclose($f);
?>

previous Printer Friendly

Advertisements


  

Advertisements