[PHP] - Output buffer based progress bar
- by KPL
Hello people,
I have been trying to get the following code working.
It's a progress bar trick which uses ob_get_clean() function.
Don't know why but this script just don't work!
Only the initial percent - 1% comes up and nothing after that.
<?php
error_reporting(8191);
function flush_buffers(){
@ob_end_flush();
@ob_flush();
@flush();
@ob_start();
}
$ini = 2;
echo '<script>document.getElementById(\'lpt\').style.width=\'1%\';</script><br>';
for($i=1;$i<=100;$i++) {
$k=$ini-1;
$str=str_replace("width=\'$k%\'","width=\'$i%\'",ob_get_clean());
$ini++;
echo $str;
flush_buffers();
}
?>