note 51950 added to function.flush

From: Date: Sat, 16 Apr 2005 15:25:38 +0000
Subject: note 51950 added to function.flush
Groups: php.notes 
Request: Send a blank email to php-notes+get-88084@lists.php.net to get a copy of this message
Remember when trying to output partial content, that PHP's .ini file setting affects whether or not it succeeds, depending on how you code it, of course. Here's an example using a progress bar done soley in PHP: // Some HTML/CSS to spice up the spaces... <html> <head> <style type="text/css"><!-- .pbar { background: #EEE; border: 1px solid #CCC; margin: 1px; height: 10px; width: 10px; }--></style> </head> <body> <?php // If the buffer is not set to 0, there's no need to call // ob_start(), because the buffer is started already. // You can test that by a call to ob_get_level();. Calling it // again will cause a second level of buffering to start and // the script won't work. if (ob_get_level() == 0) { ob_start(); } echo str_pad('Loading... ',4096)."<br />\n"; for ($i = 0; $i < 25; $i++) { echo '<span class="pbar">&nbsp;</span>'; ob_flush(); usleep(700000); } ob_end_flush(); // Close it out... ?> </body> </html> Note: This is just an example. Normally it's bad practice to use the OB like this :) This was tested with PHP 5.04 on WinXP Pro/IIS 5.1 ---- Manual Page -- http://www.php.net/manual/en/function.flush.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51950 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51950&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51950&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51950&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51950&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51950&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51950&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88084) next »