Hi,
Can someone please tell me why the code below is not flushing as I want it to? I need it to put a dot on the screen every second. All it's doing is echoing the whole thing at the end of 20 seconds. php.ini output_bufferin g is set to 0. Thanks.
Can someone please tell me why the code below is not flushing as I want it to? I need it to put a dot on the screen every second. All it's doing is echoing the whole thing at the end of 20 seconds. php.ini output_bufferin g is set to 0. Thanks.
Code:
<?php
header("Content-type: image/png");
$im = imagecreatetruecolor(600, 600);
$white = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $white);
$ptx=rand(0,600);
$pty=rand(0,600);
$xarr=array(300,0,600);
$yarr=array(0,600,600);
$i=0;
ob_start();
while($i<20)
{
$vertx=$xarr[array_rand($xarr)];
$verty=$yarr[array_search($vertx,$xarr)];
$ptx=($ptx+$vertx)*0.5;
$pty=($pty+$verty)*0.5;
imagefilledellipse($im, $ptx, $pty, 2, 2, imagecolorallocate($im, 255, 0, 0));
$i++;
ob_flush();
flush();
usleep(1000000);
}
imagepng($im);
imagedestroy($im);
?>
Comment