PHP fread() Function
Complete PHP Filesystem Reference
Definition and Usage
The fread() reads from an open file.
The function
will stop at the end of the file or when it reaches the specified length, whichever comes first.
This function returns the read string, or FALSE on failure.
Syntax
Parameter |
Description |
file |
Required. Specifies the open file to read from |
length |
Required. Specifies the maximum number of bytes to read |
Tips and Notes
Tip: This function is binary-safe (meaning that both binary data, like
images, and character data can be written with this function).
Example 1
Read 10 bytes from file:
<?php
$file = fopen("test.txt","r");
fread($file,"10");
fclose($file);
?>
|
Example 2
Read entire file:
<?php
$file = fopen("test.txt","r");
fread($file,filesize("test.txt"));
fclose($file);
?>
|
Complete PHP Filesystem Reference
The Altova MissionKit is a suite of intelligent XML tools, including:
XMLSpy® – industry-leading XML editor
- Support for all XML-based technologies
- Graphical editing views, powerful debuggers, code generation, & more
MapForce® – graphical data mapping tool
- Drag-and-drop data conversion with code generation
- Support for XML, DBs, EDI, Excel® 2007, text, Web services
StyleVision® – visual stylesheet designer
- Drag-and-drop stylesheet design for XML & databases
- Output to HTML, PDF, RTF, Word 2007, & more
And more…
Try before you buy with a free fully functional 30-day trial
Download today
|