Search code examples
phpphp4

Is there an output difference between php 4 and 5?


I noticed the other day that a new script I wrote for php 5 began outputting html that was viewable before the php script had actually finished. Did this happen with 4?

For instance, I have a long loop that echos something out with each iteration. The output was small in terms of kb, so I dont think it was lag due to the download speed. Can someone explain the difference in output?


Solution

  • Maybe there a difference in the configuration of the output_buffering directive, in php.ini ?

    If output_buffering is enabled, PHP will "keep" the generated output in memory (at least, if it doesn't become bigger than the size of the memory buffer), and only send it to the browser when the page's generation is finished.

    If output_buffering is disabled, the ouput is sent immediatly when generated, even if the script's execution is not finished yet.