| ||
File Truncate
When you open a file for writing with option 'w' it completely wipes all data from that file. This action is also referred to as "truncating" a file. Truncate literally means to shorten. File Open: Truncate To erase all the data from a file we need to open the file for normal writing. All existing data within the file will be lost. PHP Code:
$myFile = "testFile.txt"; $fh = fopen($myfile, 'w'); fclose($fh); Truncate: Why Use It
Truncating is most often used on files that contain data that will only be used for a short time. These type of files are most often referred to as temporary files. Note |