0

I have been experimenting with:

ob_implicit_flush(true);
ob_start();
$timelimit=10;
while ($timelimit>=0){
    $timelimit=$timelimit-1;
    echo "1";
    sleep(1);
    flush();
    ob_flush();
}

ob_end_flush(); 

php.ini:

output_buffering = Off

I expect to see "1" added every second until the script completes execution. Instead I see everything only after the script has ended.

What am I doing wrong here?

8
  • What's the point of the experiment? What exactly are you planing to accomplish? Commented Sep 16, 2017 at 9:16
  • Learning. But later on I hope to apply it to other things I am working on. I would be happy if it just show another "1" every second. Commented Sep 16, 2017 at 9:18
  • @MoonEater916 Why are you using the ob_*() functions? Commented Sep 16, 2017 at 9:24
  • I just saw it in other examples and copied and when that didn't work i added Flush() to try again. Commented Sep 16, 2017 at 9:29
  • Possible duplicate of In script PHP output buffer settings ignored by server Commented Sep 16, 2017 at 9:40

1 Answer 1

0

It was working the whole time. I was calling the php via ajax not realizing that the ajax was the cuplrit

if ((this.readyState == 4 || this.readyState == 3) && this.status == 200) {
Sign up to request clarification or add additional context in comments.

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.