File Truncate

File Truncate

Posted in : PHP Posted on : January 6, 2011 at 5:04 PM Comments : [ 0 ]

This section contains the detail about File Truncate In PHP.

File Truncate

In PHP, file truncation is the process of deleting data of a file. For this, we don't need any special function or method. This will be done automatically by opening file  in the write mode.

Why we need file truncate

Sometimes, we need to store data for short span of time and it need to update after some interval. In that case, truncation is helpful to truncate these temporary files.

Example :

// PHP code to truncate a file
$myFileName = 'C:\testFile.txt';
$myFileHandle = fopen($myFileName, 'w') or die("cant open file");

This will truncate/wipe out the previously existing data in the text file 'testFile.txt'.

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics