1

Firstly, I want to echo text and ,after 5 seconds,I want to echo another text. So I write...

<?php

echo 'Text';
flush();

sleep(5);

flush();
echo 'Another Text';


?>

But I see both of (Text Another Text ) after 5 seconds.How can I do for this?

1
  • For intervals and timers it would be better to use javascript. Is this possible for you? Commented Aug 3, 2011 at 11:18

4 Answers 4

1

From documentation

Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.

So you see both TextAnother Texttogether.

Sign up to request clarification or add additional context in comments.

Comments

0

Take a look at output buffering.

Comments

0

Have you started output buffering at some time? If so, you need to use ob_end_flush() to flush.

Comments

0

Switch off output buffering if you have it on or call ob_flush() too. Any output compressing (like gzip) will also mess it up. If it doesn't work try modifying these two php.ini directives to:

output_buffering = off

zlib.output_compression = off

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.