English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The fread() function can read data from the opened file. This function can stop at the end of the file or at the specified length, whichever comes first. The function can return the read string or false if it fails.
string fread ( resource $handle , int $length )
The fread() function can read the maximum number of bytes from the file pointer referenced by the handle.
<?php $filename = "sample.txt"; $handle = fopen($filename, "r"); echo fread($handle, "30); fclose($handle); ?>
Output result
w3codebox Tutorix Hello
<?php $filename = "sample.txt"; $file = fopen($filename, "r"); $contents = fread($file, filesize($filename)); echo $contents; fclose($file); ?>
Output result
w3codebox Tutorix Hello oldtoolbag.com!!!!