fread() function reads up to length bytes from the file, returning the file's contents. : fread « File Directory « PHP






fread() function reads up to length bytes from the file, returning the file's contents.

 
Its syntax is: string fread (int filepointer, int length)

Reading stops either when length bytes have been read or when the end of the file has been reached. 

<?
    $fh = fopen('data.txt', "r") or die("Can't open file!");
    $file = fread($fh, filesize($fh));
    print $file;
    fclose($fh);
?>
  
  








Related examples in the same category

1.Reading a file
2.fread( ) is good for when you only care about a small part of the file.
3.fread.php
4.fopen( ) and fread( )
5.Reading and Writing Binary Data in a File