php script appearance in the time

php script appearance in the time

am 15.08.2007 08:31:54 von Lionel

Hello,

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

echo "test 1
" ;
sleep(3);
echo "test 2
" ;

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

Re: php script appearance in the time

am 15.08.2007 08:42:42 von Dave Williams

lionel wrote:
> Hello,
>
> This is a simple script I test in a browser (firefox & opera) :
>
> echo "test 1
" ;
> sleep(3);
> echo "test 2
" ;
>
> 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
" ;
ob_flush();
flush();
sleep(3);
echo "test 2
" ;

Arjen
www.arjenkarel.nl

Re: php script appearance in the time

am 15.08.2007 09:54:20 von Lionel

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


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


Lionel

Re: php script appearance in the time

am 15.08.2007 10:59:23 von gosha bine

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
" ;
>> sleep(3);
>> echo "test 2
" ;
>>
>> 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
" ;
> ob_flush();
> flush();
> sleep(3);
> echo "test 2
" ;
>
> 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

Re: php script appearance in the time

am 15.08.2007 13:51:17 von Jerry Stuckle

lionel wrote:
> Hello,
>
> This is a simple script I test in a browser (firefox & opera) :
>
> echo "test 1
" ;
> sleep(3);
> echo "test 2
" ;
>
> 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
==================

Re: php script appearance in the time

am 15.08.2007 15:14:53 von 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.

Thanks for this precision.

Lionel