Horje Website
PHP ftruncate() Function – Truncates an open file to the specified length (100 bytes):

PHP ftruncate() Function – Truncates an open file to the specified length (100 bytes):

 

 
 
  1. <?php
  2. // Check filesize
  3. echo filesize("test.txt");
  4. echo "<br>";
  5. $file = fopen("test.txt", "a+");
  6. ftruncate($file,100);
  7. fclose($file);
  8. // Clear cache and check filesize again
  9. clearstatcache();
  10. echo filesize("test.txt");
  11. ?>

 

Output

792
100

Published:
November 15, 2022
Author:
admin
Category:
PHP Source Code
Views:
10

This article was posted in PHP Source Code. Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2022