note 35444 added to function.flush
| From: | php at project2501 dot plus dot com | Date: | Mon, 01 Sep 2003 14:00:44 +0000 |
| Subject: | note 35444 added to function.flush | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55405@lists.php.net to get a copy of this message | ||
a nice little script that produces a progress bar using the flush function, while creating a file of
fixed size, filled with random readable ascii characters
<!-- Clear msie buffer <?=str_repeat(":",500);?> -->
<style>
body{
font-family: courier;
size: 12px;
}
</style>
<?
ini_set("max_execution_time",3000000);
// don't let script timeout for a long time.
if(isset($amount))
{
echo "<br />Generating file of size: ".$amount." bytes";
if($amount>102400)
{
echo "<br />Estimated Processing Time: ~".(round($amount/102400)*3)."
seconds";
}
echo "<br /><br
/>↓0%.........................................100%↓<br />";
$handle = fopen("./file_$amount.dat","w");
$starttime = time();
for($i=0, $j=0 ; $i<$amount ; $i++, $j++)
{
if($j==round($amount/50))
{
echo '.';
flush();
$j=-1;
}
fwrite($handle,chr(rand(32,126)));
}
fclose($handle);
echo "<br /><br />file_$amount.dat created in ~".(time()-$starttime)."
seconds.";
}
?>
<br /><br />usage: <?=$PHP_SELF?>?amount=numberofbytes
----
Manual Page -- http://www.php.net/manual/en/function.flush.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35444
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35444&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35444&report=yes