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

  • SEARCH
  • Home
  • 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 6534879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:18:15+00:00 2026-05-25T10:18:15+00:00

i am confused about the PHP functions ob_flush() and ob_end_flush() . About the function

  • 0

i am confused about the PHP functions ob_flush() and ob_end_flush().
About the function ob_flush the manual says

The buffer contents are discarded after ob_flush() is called.This function does not destroy the output buffer like ob_end_flush() does. 

i am confused about the words discarded and destroyed here. Even if the buffer contents are discarded in case of ob_flush() they cant be accessed and even if they are destroyed as in case of ob_end_flush() they cant be accessed.
Then whats the difference between these two functions?

UPDATE:

In response to JamWaffles answer I dont understand the significance of deleting everything in the buffer but keeping the buffer vs deleting the whole buffer(freeing it) because PHP has no concept of pointers and you cant get the address of buffers so it should be immaterial whether you keep the empty buffer with you or you free it

  • 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-05-25T10:18:16+00:00Added an answer on May 25, 2026 at 10:18 am

    I think in this case they mean the same thing. ob_flush() is used when you want to flush parts of the page to the client, whereas ob_end_flush() flushes the entire buffer, then destroys the buffer. What ob_flush() does is delete everything in the buffer, but keeps the buffer itself so more data can be put into it after the ob_flush() call.


    I’ll try to explain better.

    Discarded

    Let’s say I have a nice, bright orange plastic bucket. This is my buffer. I then get some sand, representing the contents of the buffer, and fill the buffer (bucket) up. I then pick this bucket with sand in it up and pour it into a sandpit, which is my client. You’ll notice the sand is gone, yet the bucket remains. This is what is meant by the buffer contents are discarded – the buffer itself can be re-used (filled up with sand again). In memory terms, the memory is emptied but not freed, so it can be filled again.

    Destroyed

    Now, if we take our bucket again, fill it up with sand once more, empty the sand out and then set fire to the bucket because we don’t require it any longer, that’s called destroying the buffer; the data in the buffer is gone, but so is the buffer itself. In memory terms, the memory is freed for other use.


    Is this significant in PHP, without pointers, the OP asks? Well, it depends what you want to do. If you’re processing a long page, and want to (for example) send the header and sidebar to the client while you process the rest of the page for sending after it’s done, use ob_flush().

    If you want to flush something to the client without any more output after it, use ob_end_flush().


    I mean absolutely no disrespect in talking in a rather patronising tone; I wanted to make an analogy to make the definitions as clear as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am confused about default values for PHP functions. Say I have a function
This should be obvious, but I'm getting a bit confused about PHP variable scope.
http://php.about.com/od/finishedphp1/ss/php_login_code_4.htm I am really confused about three particular lines of code in this tutorial
I'm very confused about behaviour of PHP's left shift function. I'm using it on
I seem to be confused about PHP output buffering. I have code like this:
I'm just learning PHP, and I'm confused about what the purpose of the __construct()
I'm confused about how to use set_error_handler() properly, and the php documentation isn't really
I work for a php user authorization class and now I’m confused about sessions
i've just changed from ASP to php and i'm a bit confused about the
I am confused about multi-dimentional array. In the following db, php and html, I

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.