|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21120 fflush doesn`t work
Submitted: 2002-12-20 16:01 UTC Modified: 2002-12-22 09:02 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: 4.2.3 OS: win2k pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2002-12-20 16:01 UTC]
this is not the same as :)

the following code on my platform displays:
File size: 0, written: 2890
File size: 2890, written: 2890

as far as i know fflush should flush output to file at the moment of calling :] moving the line with flcose to the end of script causes that also the second display shows
File size: 0, written: 2890
it looks for me that fflush doesn`t work and all flushing is done during file closing.
tested it under linux also - both variants are done ok there:
File size: 2890, written: 2890
File size: 2890, written: 2890 

$str = '';
for($i = 0;$i < 1000;$i++) {
	$str .= $i;

$fp = fopen('test.txt', 'wb');
$written = fwrite($fp, $str);
$size = filesize('test.txt');
echo 'File size: '.$size.', written: '.$written.'<br>';
$size = filesize('test.txt');
echo 'File size: '.$size.', written: '.$written.'<br>';


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-21 12:10 UTC]
Please try using this CVS snapshot:
For Windows:

 [2002-12-21 13:19 UTC] rashid at ds dot pg dot gda dot pl
no changes with latest windows build (PHP Version 4.4.0-dev)
 [2002-12-22 09:02 UTC]
More of a "can't fix".

PHP is fflush()ing correctly, which merely causes any data buffered in a FILE* to be sent to the OS at that time.
It is up to the OS to decide when to write the data to disk.

If you sleep(1) after the fflush() call, the script works as you described, at least on my WinXP box.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jun 03 04:03:39 2023 UTC