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 when the specified length is reached, whichever comes first. This function can return the read string or false on failure.
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!!!!