How do echo out progress on MAMP using flush()

I'm trying to run a simple PHP script on MAMP. I'm using PHP 5.2.17 and I have compression turned off. Im trying to execute this simple script

    foreach(range(1,9) as $n){
    echo $n."\n";

For sme reason this is not doing what it is supposed to. Rather than sequentially echoing out the numbers, it's simply echoing them out when the loop is done. Am I missing something? is there another way to do this?


Output buffering is a mechanism for controlling how much output data (excluding headers and cookies) PHP should keep internally before pushing that data to the client. If your application's output exceeds this setting, PHP will send that data in chunks of roughly the size you specify. Turning on this setting and managing its maximum buffer size can yield some interesting side-effects depending on your application and web server. You may be able to send headers and cookies after you've already sent output through print or echo. You also may see performance benefits if your server is emitting less packets due to buffered output versus PHP streaming the output as it gets it. On production servers, 4096 bytes is a good setting for performance reasons.

Note: Output buffering can also be controlled via Output Buffering Control functions.

php.ini Possible Values:

On = Enabled and buffer is unlimited. (Use with caution) 
Off = Disabled    
Integer = Enables the buffer and sets its maximum size in bytes.  
eg: output_buffering = Off

Note: This directive is hardcoded to Off for the CLI SAPI

A Working example if output_buffering is set to 4096

// Output string to overflow browser php.ini output_buffering setting.
echo str_repeat(PHP_EOL, 4097);

for ($i=0; $i<5; $i++) {
  echo PHP_EOL.$i;

Indeed, it is the buffer size

PHP buffer why \r\n

This example worked for me

Need Your Help

PHP - how to set up URL after sending form?

php forms url post get

I have a website ( and on the homepage is a form, where the user set up a city. After sending the form, I am trying to have the following URL address:

ASP.NET How to make TextBox width dependent on GridView column's width?

c# html forms text

I need to make filters on table (GridView), on the top of each column should appear "TextBox" to enter filter values. GridView width is not fixed, column's width always changing depending on result...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.