0

I have php code like this:

<?php

While (1)echo "hello";

The server is outputing a chunk of data instead of progressively outputting each 'hello'

1
  • 2
    Google "php server push" to learn how to do real-time output from PHP. Commented Jul 11, 2016 at 22:19

1 Answer 1

4

By default, PHP output is not sent to the browser while the script executes. Nothing gets sent to the browser until the script finishes. Since your loop never ends, the script never exits, so nothing shows in the browser.

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

3 Comments

He can use ob_flush to send the buffer content to the browser immediately.
@IsmailRBOUH that's a bit of a hit-or-miss approach it wont always work
Unfortunately it doesn't always work it waits until the buffer is full and sends all the data at one time

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.