SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Nov 20, 2004, 20:16 #1
- Join Date
- Oct 2004
- Location
- Next Door
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
question, save_file function with fwrite
Hi, I have a script here downloaded from the net. It works fine, I'm just not quite clear how it works.
Code:function save_file($filename, $contents) { $i = 0; do { $handle = fopen($filename, "w+"); $fout = fwrite($handle, $contents); fclose($handle); $i++; } while(filesize($filename) < 5 && $i < 5); }
any information would be greatly appreciated.
-
Nov 20, 2004, 20:28 #2
- Join Date
- Feb 2004
- Location
- Örebro, Sweden
- Posts
- 2,716
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
It seems like the function is used to make sure that the size of the file is at least five bytes. What it does is to write $content to the specified file as long as the filesize is less than five bytes. It will not write $content to the file more than five times. Personally, I think that the function is of no use unless you want to make sure that the size of the file exceeds five bytes.
Yours, Erik.
Bookmarks