The ftruncate() function truncates the open file to the specified length.
Returns TRUE if successful and FALSE if failed.
ftruncate(file,size)
parameter | describe |
---|---|
file | Required. Specifies the open file to be truncated. |
size | Required. Specifies the new file size. |
<?php//check filesizeecho filesize("test.txt");echo "<br />";$file = fopen("test.txt", "a+");ftruncate($file,100);fclose( $file);//Clear cache and check filesize againclearstatcache();echo filesize("test.txt");?>
The above code will output:
792100