ftruncate
Truncate the file to a given length
The ftruncate()
function truncates the file to a specified length.
<?php //Check file size echo filesize ( "test.txt" ) ; echo "<br />" ; $file = fopen ( "test.txt" , "a+" ) ; ftruncate ( $file , 100 ) ; fclose ( $file ) ; //Clear the cache and check the file size again clearstatcache ( ) ; echo filesize ( "test.txt" ) ; ?>
The output is similar:
792 100
ftruncate ( file , size )
parameter | describe |
---|---|
file | Required. Specifies that the file to be truncated is opened. |
size | Required. Specify the new file size. |
Accept the file pointer file as a parameter and intercept the file size as size . Return TRUE if successful, otherwise return FALSE.