note 51950 deleted from function.flush by googleguy

From: Date: Tue, 22 Oct 2013 10:18:05 +0000
Subject: note 51950 deleted from function.flush by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196990@lists.php.net to get a copy of this message
Note Submitter: storm at stormfx dot com ---- 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

« previous php.notes (#196990) next »