Definition :
The PHP ftruncate() function truncates an open file to the specified length.
Syntax
ftruncate(file, size)
Parameter | Description |
---|---|
file | Required. Specifies the open file to truncate |
size | Required. Specifies the new file size |
Lets assume that we have a file called demo.txt. This file contains following content:
This is a demo file.
It contains dummy content.
In the example below, the content of the file is displayed before and after truncating its content.
Output :
This is a demo file. It contains dummy content.
This is a demo