note 47312 added to function.flush

From: Date: Thu, 11 Nov 2004 00:26:00 +0000
Subject: note 47312 added to function.flush
Groups: php.notes 
Request: Send a blank email to php-notes+get-80381@lists.php.net to get a copy of this message
This code does not work as expected <pre> <?php echo "Test1\n"; flush(); sleep(3); echo "Test2\n"; ?> </pre> It should print Test1, wait 3 seconds then print Test2 but actually it prints everything at the end. It seems PHP is doing output buffering on its own, here is the way to make it work : <pre> <?php ob_end_flush(); echo "Test1\n"; flush(); sleep(3); echo "Test2\n"; ?> </pre> You don't really need to repeat some "fake" text to fill the buffer in order to make this effect. ---- Manual Page -- http://www.php.net/manual/en/function.flush.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47312 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47312&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47312&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47312&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47312&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47312&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47312&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47312&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80381) next »