php script appearance in the time

This is a discussion on php script appearance in the time within the PHP Language forums, part of the PHP Programming Forums category; Hello, This is a simple script I test in a browser (firefox & opera) : echo "test 1<br /&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-15-2007
lionel
 
Posts: n/a
Default php script appearance in the time

Hello,

This is a simple script I test in a browser (firefox & opera) :

echo "test 1<br />" ;
sleep(3);
echo "test 2<br />" ;

I expected to see "test 1" appearing first and then "test 2" 3 sec after.
Still, I got "test 1" & "test 2" appearing "in one shot" after 3 seconds.
How can I get what I expected (I precised in a browser because there's no pb
in a command line execution) ?

Thanks in advance,

Lionel


Reply With Quote
  #2 (permalink)  
Old 08-15-2007
Arjen
 
Posts: n/a
Default Re: php script appearance in the time

lionel wrote:
> Hello,
>
> This is a simple script I test in a browser (firefox & opera) :
>
> echo "test 1<br />" ;
> sleep(3);
> echo "test 2<br />" ;
>
> I expected to see "test 1" appearing first and then "test 2" 3 sec after.
> Still, I got "test 1" & "test 2" appearing "in one shot" after 3 seconds.
> How can I get what I expected (I precised in a browser because there's no pb
> in a command line execution) ?
>
> Thanks in advance,
>
> Lionel


Try this

echo "test 1<br />" ;
ob_flush();
flush();
sleep(3);
echo "test 2<br />" ;

Arjen
www.arjenkarel.nl

Reply With Quote
  #3 (permalink)  
Old 08-15-2007
lionel
 
Posts: n/a
Default Re: php script appearance in the time

> Try this
>
> echo "test 1<br />" ;
> ob_flush();
> flush();
> sleep(3);
> echo "test 2<br />" ;
>
> Arjen
> www.arjenkarel.nl



It nearly works, I got a notice message. Adding "on_start();" at the
beginning makes it disappear.
Thank you.


Lionel


Reply With Quote
  #4 (permalink)  
Old 08-15-2007
gosha bine
 
Posts: n/a
Default Re: php script appearance in the time

On 15.08.2007 08:42 Arjen wrote:
> lionel wrote:
>> Hello,
>>
>> This is a simple script I test in a browser (firefox & opera) :
>>
>> echo "test 1<br />" ;
>> sleep(3);
>> echo "test 2<br />" ;
>>
>> I expected to see "test 1" appearing first and then "test 2" 3 sec after.
>> Still, I got "test 1" & "test 2" appearing "in one shot" after 3 seconds.
>> How can I get what I expected (I precised in a browser because there's
>> no pb in a command line execution) ?
>>
>> Thanks in advance,
>>
>> Lionel

>
> Try this
>
> echo "test 1<br />" ;
> ob_flush();
> flush();
> sleep(3);
> echo "test 2<br />" ;
>
> Arjen
> www.arjenkarel.nl
>


not ob_flush, just flush()


--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Reply With Quote
  #5 (permalink)  
Old 08-15-2007
Jerry Stuckle
 
Posts: n/a
Default Re: php script appearance in the time

lionel wrote:
> Hello,
>
> This is a simple script I test in a browser (firefox & opera) :
>
> echo "test 1<br />" ;
> sleep(3);
> echo "test 2<br />" ;
>
> I expected to see "test 1" appearing first and then "test 2" 3 sec after.
> Still, I got "test 1" & "test 2" appearing "in one shot" after 3 seconds.
> How can I get what I expected (I precised in a browser because there's no pb
> in a command line execution) ?
>
> Thanks in advance,
>
> Lionel
>
>


You can't do it reliably.

You can control what your code does. You can even control the PHP
buffering. But you can't control buffering in the web server, which may
delay the output until the buffer fills or the entire page is sent. You
also cannot control the browser, which may delay displaying the data
until the entire page is received.

You can flush buffers and get it to work much of the time. But not
necessarily all the time.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #6 (permalink)  
Old 08-15-2007
lionel
 
Posts: n/a
Default Re: php script appearance in the time

> You can't do it reliably.
>
> You can control what your code does. You can even control the PHP
> buffering. But you can't control buffering in the web server, which may
> delay the output until the buffer fills or the entire page is sent. You
> also cannot control the browser, which may delay displaying the data until
> the entire page is received.
>
> You can flush buffers and get it to work much of the time. But not
> necessarily all the time.


Thanks for this precision.

Lionel


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:09 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0