Re: [PHP] ob_flush() problems

2006-05-31 Thread Brad Bonkoski



cajbecu wrote:


Hello,

   for ($i=0; $i  10; $i++) {
   $output = ccc2;
   print pre;
   echo $output;
   print /pre;
   ob_flush();
   flush();

   sleep(1);
   }

I want to show on the browser, ccc2 (example) every 1 second, but it
shows all the text when the for stops... any ideea?

i tried all the examples from php.net, all the examples on the net,
bot no succes.

cheers,

PHP is a server side scripting language, so the information would not be 
sent to the browser( aka client) until the server side script has 
completed its execution.

-Brad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_flush() problems

2006-05-31 Thread Adam Zey

Brad Bonkoski wrote:



cajbecu wrote:


Hello,

   for ($i=0; $i  10; $i++) {
   $output = ccc2;
   print pre;
   echo $output;
   print /pre;
   ob_flush();
   flush();

   sleep(1);
   }

I want to show on the browser, ccc2 (example) every 1 second, but it
shows all the text when the for stops... any ideea?

i tried all the examples from php.net, all the examples on the net,
bot no succes.

cheers,

PHP is a server side scripting language, so the information would not be 
sent to the browser( aka client) until the server side script has 
completed its execution.

-Brad


That is incorrect. There is nothing stopping a PHP script from doing 
exactly what he says, and being a server-side script doesn't imply that 
the data will be buffered.


I suggest that both of you examine the contents of 
http://www.php.net/manual/en/function.flush.php for more information on 
obstacles to getting data to the client as it is generated.


As an unrelated note, there is no point in using print for some things 
and echo for others. For your uses, you might as well just use echo 
for everything.


Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_flush() problems

2006-05-31 Thread Richard Lynch
On Wed, May 31, 2006 1:29 pm, cajbecu wrote:
 for ($i=0; $i  10; $i++) {
 $output = ccc2;
 print pre;
 echo $output;
 print /pre;
 ob_flush();
 flush();

 sleep(1);
 }

 I want to show on the browser, ccc2 (example) every 1 second, but it
 shows all the text when the for stops... any ideea?

 i tried all the examples from php.net, all the examples on the net,
 bot no succes.

ob_flush() only makes sense if you have ob_start() somewhere, or if
output_buffering is enabled in php.ini

flush(); and sleep(1); are all you should need...

At least from PHP standpoint.

But there are many other players outside the control of PHP...

Apache could be buffering output.

TCP could be buffering output.

Your browser will NOT render some parts of some elements until the
tags are all closed -- If you are inside a TABLE, for instance, expect
not to see things happening in real-time.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_flush() problems

2006-05-31 Thread Richard Lynch
On Wed, May 31, 2006 1:36 pm, Brad Bonkoski wrote:
 PHP is a server side scripting language, so the information would not
 be
 sent to the browser( aka client) until the server side script has
 completed its execution.

This is just plain incorrect.

While buffering within various pieces of software MAY alter the
timing, data IS output from PHP as it runs, not only after execution
is completed.

If you pump ENOUGH data out, and then sleep(10) and then pump ENOUGH
more data out, you WILL see the data in parallel with script
execution.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php