You are viewing documentation for an outdated version. It is no longer supported!
Truncate
To truncate the stream to a specific size, use truncate()
.
$stream = FileStream::open('persons.txt', 'r')
->truncate(0);
echo $stream->getSize(); // 0
$stream = FileStream::open('persons.txt', 'r')
->truncate(25);
echo $stream->getSize(); // 25
Behind the scene, PHP's ftruncate()
is used to truncate stream.