PHP Function Ftruncate
php function ftruncate is an inbuilt php function which is used to truncate(shorten) an open file to the specified length. It accepts two parameters, file and size, and returns True on success and False on failure.
You must first open the file you want to truncate using the fopen() function and set the mode to w. Then, call ftruncate with the file pointer and the new size. Finally, close the file with fclose().
The ftruncate function works by comparing the new size to the old one, and if it is smaller, rewinds (decrements) the file pointer to a position before the start of the data and truncates the remaining data to that offset. The original data is still stored on disk, but it can't be accessed as the file pointer is repositioned after the truncate operation.
RFCs and major pull-requests discussed, voted on, and implemented since our last update
Ilija Tovilo and Larry Garfield proposed a new RFC to allow granular visibility conditions for class property set operations (such as assigning a value) to be restricted to private scope only. This would be similar to the __clone() magic method that allows you to clone a class and change its properties.
The RFC was voted on and approved in the 8.3 release of PHP. See the changelog for more details.