caching - Whats the point of using ob_start without any parameters in PHP -


I can see the use with the output_callback parameter set but I do not see the usage Calling ob_start is called without any parameters.

Can the issue of disabling output later throw all the output together? Does not it use more memory (server side) and slow download (client side) because the download starts only after rendering (or when called)?

  ob_start (); For ($ i = 1; $ i & lt; = 15; $ i ++) {echo $ i, ''; Sleep (1); } Ob_end_flush ();  

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

One reason, to "hold" the production of a small part of the code.

So, we say that you have an independent piece of code that you want to execute, but you do not want to directly output it directly, what can you do,

< Pre> ob_start (); Include 'file.php'; $ Output = ob_get_clean ();

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

  ob_start (); Phpinfo (); $ Info = ob_get_clean (); // Remove Massage, Principle, HTML, Head, and Body Tags from Production $ info;  

I also use it with visual files. In the visual category, the __ toString () method actually provides the view. But since a code is expected to be returned from __ toString () , then I use the output buffering to capture the template and it should be returned ...

< / Div>

Comments