PHP fwrite() Functie
❮ Referentie voor PHP-bestandssysteemVoorbeeld
Schrijf naar een geopend bestand:
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>
De uitvoer van de bovenstaande code zal zijn:
21
Definitie en gebruik
De fwrite() schrijft naar een open bestand.
De functie stopt aan het einde van het bestand (EOF) of wanneer het de opgegeven lengte bereikt, afhankelijk van wat zich het eerst voordoet.
Syntaxis
fwrite(file, string, length)
Parameterwaarden
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 |
Technische details
Winstwaarde: | Het aantal geschreven bytes, ONWAAR bij fout |
---|---|
PHP-versie: | 4.0+ |
Binaire kluis: | Ja |
❮ Referentie voor PHP-bestandssysteem