PHP fread() Functie
❮ Referentie voor PHP-bestandssysteemVoorbeeld
Lees 10 bytes uit een geopend bestand:
<?php
$file = fopen("test.txt","r");
fread($file,"10");
fclose($file);
?>
Definitie en gebruik
De fread() leest uit een geopend bestand.
De functie stopt aan het einde van het bestand of wanneer het de opgegeven lengte bereikt, afhankelijk van wat zich het eerst voordoet.
Syntaxis
fread(file, length)
Parameterwaarden
Parameter | Description |
---|---|
file | Required. Specifies the open file to read from |
length | Required. Specifies the maximum number of bytes to read |
Technische details
Winstwaarde: | De leesreeks, ONWAAR bij fout |
---|---|
PHP-versie: | 4.0+ |
Binaire kluis: | Ja |
Meer voorbeelden
Voorbeeld
Lees het hele bestand:
<?php
$file = fopen("test.txt","r");
fread($file,filesize("test.txt"));
fclose($file);
?>
❮ Referentie voor PHP-bestandssysteem