← All built-ins / fread()

fread()

fread(...$args): string

Parameters

NameTypeDescription
$handleresourcehandle from fopen()
$maxintmaximum bytes to read

Return value

Up to $max bytes as a string.

Example

file_put_contents("/tmp/hphp_doc_fr.txt", "abcdef");
$fh = fopen("/tmp/hphp_doc_fr.txt", "rb");
echo fread($fh, 3);
fclose($fh);
abc

See also

fgets()file_get_contents()feof()