What is output buffering in PHP , why should we use it ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dinesh1440
    New Member
    • May 2010
    • 16

    What is output buffering in PHP , why should we use it ?

    What is the advantage of using output buffering? Why do we need to hold the output from printing in the browser?
    Thank you.
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    Headers can't be sent if anything has been output to the browser, using output buffering allows you to get around this. Your output goes to the buffer and you can send your headers even after something has been printed.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Once output has been sent to the browser, no more headers can be sent. This is sometimes a problem. So, with output-buffering, you can defer the output into a buffer until such time that you deem it OK to send to the browser.

      Comment

      • HaLo2FrEeEk
        Contributor
        • Feb 2007
        • 404

        #4
        That's what I said, if my answer was right you could have just agreed with it.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Sorry, HaLo. I had opened this thread before you replied, but then got distracted. By the time I'd posted my reply, you'd already done so, too, though I wasn't aware.

          Comment

          • HaLo2FrEeEk
            Contributor
            • Feb 2007
            • 404

            #6
            Ah, my apologies, I didn't mean to sound like a jerk, just thought you were trying to steal mah thunda ;)

            Comment

            Working...