Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    Pennsylvania, United States
    Posts
    54
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Exclamation Quick output buffering question.

    According to the PHP manual, 'While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.'

    To my knowledge, I'm guessing this means, only headers will be sent, but anything echo()ed or print()ed will do just that when ob_get_contents(), ob_end_clean() or ob_end_flush() is called. Is this correct?

    Thanks!

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Thats correct, ob_end_flush is also implicitly called at script end if ob is stacked. OB also allows you to stack your buffers.
    Output buffering is the only way to allow headers to be sent after body, but a correction to the source to never print before all headers are sent is adviseable.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    johnnnn (05-22-2010)

  • #3
    New Coder
    Join Date
    May 2009
    Location
    Pennsylvania, United States
    Posts
    54
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Thats correct, ob_end_flush is also implicitly called at script end if ob is stacked. OB also allows you to stack your buffers.
    Output buffering is the only way to allow headers to be sent after body, but a correction to the source to never print before all headers are sent is adviseable.
    Thank you, this answered my question!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •