Вопрос

<?php
ini_set('output_buffering','0');
echo 'Begin ...<br />';
for( $i = 0 ; $i < 10 ; $i++ )
{
    echo $i . '<br />';
    flush();
    ob_flush();
    sleep(1);
}
echo 'End ...<br />';
?>

In the code above I am trying to set output_buffering as off, but it is not working.

Output is echoing at the end of execution of script.

Это было полезно?

Решение

Другие советы

Instead of using ob_flush, just use ob_end_flush at the beginning of your script to remove the output buffer.

Also, declare the character encoding of your page, so the browser can show your output right away without having to look at hundreds of input bytes first:

header('Content-Type: text/html; charset=utf-8');

If your script still does not work, the web server is Apache, and you can create a .htaccess file, try doing so with the following contents:

php_flag zlib.output_compression Off

By the way, the ini_set is useless, and you should also include html, head, and body elements. At least for Firefox, including these elements also solves the problem:

echo '<!DOCTYPE html><html><head><title>test</title></head><body>';
// ...
echo '</body></html>';
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top