0

Hi all,
I am running a script that processes files line by line.
It takes a while so I would like to echo a status update with each line so we can see where we are in the process.
I started reading on the output buffers but that doesn't do what I want.
My code (with the essential lines here) is:

<?php

ob_start();
echo 'Start the process';
ob_flush();

// here I open a file and read it into an array, left out to keep it simple.

foreach ($uniqlist as $regel)
{
echo 'we are on line ' . $regel .' <br>';
ob_flush();
}
echo 'Finished';
ob_end_flush();

?>

Any ideas of why the output buffering is not doing what I expected?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Robbastiaansen
0

Hi Chrishea,
Thanks for pointing me to the documentation. Now I have tried the example:

<?php
ob_start();
for($i=0;$i<70;$i++)
{
echo 'printing...<br />';
ob_flush();
flush();
usleep(300000);
}
?>

I have placed this in a file, on my site, and when I call it it still just waits until the entire for-loop is finished and then dumps the entire output to my browser. I had expected it to print it line by line.
So I am doing something wrong here?
Rob

0

Hi P0IT10n,
So you are suggesting that I use double quotes in stead of single quotes?
I have tried the sample from the manual with double quotes, but that doesn't matter either.
It sill runs through the entire for and then dumps it to my browser, the test that I had described in my post that is also in the manual is on-lien here: http://www.gpsopleiding.nl/test.php
You can see that it doesn't print line by line.
And that is what I want
Rob

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.