Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8162981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:54:41+00:00 2026-06-06T18:54:41+00:00

We have a ubuntu test server that this simple script works fine on where

  • 0

We have a ubuntu test server that this simple script works fine on where it outputs a number each second to the browser

<?
    for ($i=0; $i<3; $i++) 
    {
        echo $i.'<br>';
        flush();
        sleep(1);
    }

However on my local development box (windows environment) I cannot get it to work, it outputs it all after 3 seconds.

I am using the same php version (5.3.13) as well as apache (2.2.22) version on my local box as the test server.
I have mirrored most of the settings in both php.ini as well as the httpd.conf
Here are settings I have set (which are identical to the test server)

output_buffering 0
zlib.output_compression = Off
zlib.output_compression_level = -1

I don’t have mod_gzip installed.

I have even tried doing a wamp install on my box, and it didn’t work with that either.

I can’t imagine it being a client (browser — firefox 13) issue as I use the exact same browser to view the script on the test server and it works fine

I have tried enabling implicit flush, doing ob_flush, etc. No luck.

Anyone have any ideas on how to get this working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:54:43+00:00Added an answer on June 6, 2026 at 6:54 pm

    Just keep in mind what @Wrikken said, this is not recommended.

    So I was thinking, everything you’re doing seems to be right. I copied your setup and tried. I faced same problem. I executed the script from command line, it worked.

    Then I had to do the last test, Wireshark. Following the first couple of packets it was clear that the server is sending everything correctly, so it had to be the browser’s buffer.

    So I tried send some data before the loop, well guess what? It worked!

    Here you go:

    <?php
    ini_set('output_buffering','off');
    ini_set('zlib.output_compression', 0);
    echo str_repeat(" ", 1024), "\n";
    for($i=0;$i<6;$i++) {
          echo $i."<br />\n";
          ob_flush();
          flush();
          sleep(1);
    }
    ?>
    

    I’m not sure about the application you have in mind, but this is clearly not a good idea, I highly recommend that you look into other options.

    Update:
    After a lengthy Google search I found this and this

    Because a browser cannot correctly render a page without knowing how
    to construct the page’s characters, most browsers buffer a certain
    number of bytes before executing any JavaScript or drawing the page

    And

    To avoid these delays, you should always specify the character
    encoding as early as possible, for any HTML document larger than 1 KB
    (1024 bytes, to be precise, which is the maximum buffer limit used by
    any of the browsers we have tested).

    So I tried to send the charset first instead of filling the buffer: (and it worked)

    <?php
    ini_set('output_buffering','off');
    ini_set('zlib.output_compression', 0);
    //echo str_repeat(" ", 1024), "\n";
    header('Content-Type: text/html; charset=iso-8859-1');
    //Note that it shoudn't matter which charset you send
    for($i=0;$i<6;$i++) {
          echo $i."<br />\n";
          ob_flush();
          flush();
          sleep(1);
    }
    ?>
    

    So why was it working with the first server but not the second?

    Most likely it’s because your first server is sending the charset with the header while the second one isn’t.

    In your case, however, I’d make the following changes

    <?php
    ini_set('output_buffering','off');
    ini_set('zlib.output_compression', 0);
    //Plain text MIME type since you'll use for logging purposes
    //and if you run it from CLI, you can ignore the whole header line
    header('Content-Type: text/plain; charset=iso-8859-1');
    for($i=0;$i<6;$i++) {
          //No need to echo <br /> once you'll run it from CLI
          echo $i."\n";
          ob_flush();
          flush();
          sleep(1);
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHPMyAdmin in a Ubuntu desktop test server box that I have just installed
I have a very simple test page that uses XHR requests with jQuery's $.getJSON
I have installed openjdk+tomcat7 on ubuntu EC2 instance. After do some test http and
I have Ubuntu 11.10, and I have always run python just fine. However I
I have an Ubuntu server on linode running a node.js/mongo app. I realize I
I have a ubuntu pc's in internal sub-network that I'm running mongo on them.
I have an ubuntu server with mysql installed, at one point I saw the
I have computer (ubuntu server). Server have internet and share internet for local network.
I know that this question have been asked several times. But I can't get
I am working in ubuntu server 10.04 I am creating a test.h file which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.