Funkce PHP fwrite().
❮ Reference souborového systému PHPPříklad
Zápis do otevřeného souboru:
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>
Výstupem výše uvedeného kódu bude:
21
Definice a použití
Funkce fwrite() zapisuje do otevřeného souboru.
Funkce se zastaví na konci souboru (EOF) nebo když dosáhne zadané délky, podle toho, co nastane dříve.
Syntax
fwrite(file, string, length)
Hodnoty parametrů
Parameter | Description |
---|---|
file | Required. Specifies the open file to write to |
string | Required. Specifies the string to write to the open file |
length | Optional. Specifies the maximum number of bytes to write |
Technické údaje
Návratová hodnota: | Počet zapsaných bajtů, FALSE při selhání |
---|---|
Verze PHP: | 4,0+ |
Binární trezor: | Ano |
❮ Reference souborového systému PHP