PHP ftruncate() Functie
❮ Referentie voor PHP-bestandssysteemVoorbeeld
Kapt een geopend bestand af tot de opgegeven lengte (100 bytes):
<?php
// Check filesize
echo filesize("test.txt");
echo "<br>";
$file = fopen("test.txt", "a+");
ftruncate($file,100);
fclose($file);
// Clear cache and check filesize again
clearstatcache();
echo filesize("test.txt");
?>
De uitvoer van de bovenstaande code zal zijn:
792
100
Definitie en gebruik
De functie ftruncate() kapt een geopend bestand af tot de opgegeven lengte.
Syntaxis
ftruncate(file, size)
Parameterwaarden
Parameter | Description |
---|---|
file | Required. Specifies the open file to truncate |
size | Required. Specifies the new file size |
Technische details
Winstwaarde: | WAAR bij succes, of ONWAAR bij mislukking. |
---|---|
PHP-versie: | 4.0+ |
❮ Referentie voor PHP-bestandssysteem