Open a file and read 10 bytes from it:
<?php $file = fopen(“test.txt”,“r”); fread($file,“10”); fclose($file); ?> |
Fread() retrieves data from an open file.
Upon reaching the given length or the end of the file, whichever occurs first, the function will terminate.Reword
fread(file, length) |
Parameter |
Description |
file |
Essential. indicates the open file that will be read. |
length |
Essential. indicates the most bytes that can be read. |
Return Value: |
The read string; if it fails, FALSE |
PHP Version: |
4.0+ |
Binary Safe: |
Yes |
Go through the full file:Reword
<?php $file = fopen(“test.txt”,“r”); fread($file,filesize(“test.txt”)); fclose($file); ?> |