Funkce PHP fread().
❮ Reference souborového systému PHPPříklad
Přečíst 10 bajtů z otevřeného souboru:
<?php
$file = fopen("test.txt","r");
fread($file,"10");
fclose($file);
?>
Definice a použití
Funkce fread() čte z otevřeného souboru.
Funkce se zastaví na konci souboru nebo když dosáhne zadané délky, podle toho, co nastane dříve.
Syntax
fread(file, length)
Hodnoty parametrů
Parameter | Description |
---|---|
file | Required. Specifies the open file to read from |
length | Required. Specifies the maximum number of bytes to read |
Technické údaje
Návratová hodnota: | Čtený řetězec, FALSE při selhání |
---|---|
Verze PHP: | 4,0+ |
Binární trezor: | Ano |
Další příklady
Příklad
Přečíst celý soubor:
<?php
$file = fopen("test.txt","r");
fread($file,filesize("test.txt"));
fclose($file);
?>
❮ Reference souborového systému PHP