Is ob_start() used for output buffering so that the headers are buffered and not sent to the browser? Am I making sense here? If not then why should we use ob_start()?
Is ob_start() used for output buffering so that the headers are buffered and not
Share
Think of
ob_start()as saying “Start remembering everything that would normally be outputted, but don’t quite do anything with it yet.”For example:
There are two other functions you typically pair it with:
ob_get_contents(), which basically gives you whatever has been “saved” to the buffer since it was turned on withob_start(), and thenob_end_clean()orob_flush(), which either stops saving things and discards whatever was saved, or stops saving and outputs it all at once, respectively.