I honestly don't know, but there must be something similar in PHP. I know in Perl, you would just use:
$| = 1;
That will make it so the output is displayed immediately, instead of waiting until the end of execution. There must be something similar in PHP, but sorry, no idea...