[SOLVED] .txt flush
Moderator: General Moderators
.txt flush
Is there any function or method in PHP to flush the contents of a .txt file on your server. I have been doing some practice with coding and I am sort of confused at this part. Any help appreciated?
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
There's fflush: http://us2.php.net/manual/en/function.fflush.php
but that flushes the data buffer.
If your trying to clear a file? That is delete the data and not the file then ...
1. Creating a empty temporary file.
2. Renaming that temp file to one you want cleared.
This is an atomic operation (on linux) so anyone reading the old file can finish.
Like Wayne said a little more detail might help?
but that flushes the data buffer.
If your trying to clear a file? That is delete the data and not the file then ...
1. Creating a empty temporary file.
2. Renaming that temp file to one you want cleared.
This is an atomic operation (on linux) so anyone reading the old file can finish.
Like Wayne said a little more detail might help?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
or just:Buddha443556 wrote:There's fflush: http://us2.php.net/manual/en/function.fflush.php
but that flushes the data buffer.
If your trying to clear a file? That is delete the data and not the file then ...
1. Creating a empty temporary file.
2. Renaming that temp file to one you want cleared.
This is an atomic operation (on linux) so anyone reading the old file can finish.
Like Wayne said a little more detail might help?
Code: Select all
<?php
fclose(fopen('filename','wb'));
?>