As stated above, the Web server buffers content sent to the browser, and you can request that the buffer be flushed. PHP4 introduced a new mechanism for buffering output you can control completely. Four functions control PHP's output buffer: ob_start, ob_end_flush, ob_end_clean, and ob_ get_contents.
When you call the ob_start function, anything you send to the browser is placed into a buffer. This includes text outside of PHP tags. The Web server will not receive this content until the ob_end_flush function is called. There are several powerful applications of these functions. One is to avoid the problem associated with sending headers. Because all headers are sent at once, before any content, you have to take care when using the header function. This results in a script design where early parts of a script are declared a "no output" zone, which can be annoying. If you use output buffering, you can safely add headers to the stack where you wish, and delay sending content until the last line of your script.
Another application of these functions is in building HTML tables. Imagine creating a table filled with data from a database. You first print the opening tags for the table. You execute a query and loop over the results being returned. If everything executes without error, you print a closing table tag. If an error occurs within the loop, you may have to abort, and the code that closes the table is never reached. This is bad because of the behavior of Netscape Navigator: It won't display information inside an unclosed table. The solution is to turn on output buffering before assembling the table. If assembly completes successfully, you can flush the buffer. Otherwise you can use ob_end_clean, which throws away anything in the buffer.
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.