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 870807
In Process

The Archive Base Latest Questions

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

I can see the use of ob_start with the output_callback parameter set but I

  • 0

I can see the use of ob_start with the output_callback parameter set but I can’t see the use of ob_start when calling it without any parameters set at all.

Whats the point of disabling output to later throw all the output at once? Doesn’t this use more memory (server side) and slow downloads (client side) since the download starts only after the page is fully rendered (or when ob_end_flush is called)?

ob_start();
for ($i = 1; $i <= 15; $i++)
{
    echo $i, ' ';
    sleep(1);
}
ob_end_flush();

Anyone can give me the usage/advantages of using ob_start() without any parameters set (like in the snippet above).

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

    One reason, is to “grab” the output of a small section of code.

    So, let’s say that you have an independent piece of code that you want to execute, but you don’t want to just output it directly. What you can do, is

    ob_start();
    include 'file.php';
    $output = ob_get_clean();
    

    I’ll give you a real world example. Say you are building an installer for an application. And as part of that installer you want to show the current PHP information (the data from phpinfo()). But, you want to integrate that information with the rest of the page (rather than use a frame). So, what you can do is grab the output of phpinfo() with an output buffer, modify it, and then display it where you want in your template file.

    ob_start();
    phpinfo();
    $info = ob_get_clean();
    //Massage the output, remove the doctype, html, head, and body tags
    echo $info;
    

    I also use it with view files. In the View class, the __toString() method actually renders the view. But since __toString() is expected to return a string rather than echo it, I use output buffering to capture the template and return it…

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

Sidebar

Related Questions

I'm reading about AST (abstract syntax trees) but all the samples I see use
Is there any sample code where I can see the use of scope interceptor
I can see how you can use the Acl Extension to control the push/pull
I can see there are many ways to use jQuery safely in the javascript
Should I use E_NOTICE enabled on live server? As I can see in Why
Im trying to use this page slider jquery plugin, you can see the demo
Looking at examples about socket programming, we can see that some people use AF_INET
What tool or method can I use to see what code something like an
I see how you can use query functions to apply different weights to different
Please see the jQuery below: I am really wondering how can I use CSS

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.