What is ob_start in php ?

The PHP output buffering will save all the server outputs ( html and php prints) to a string variable.

So to start buffering, use ob_start(); this will keep saved any output.
Then you use $variable = ob_get_clean(); to stop buffering, and copy the buffer content to the variable.

Here are few samples of the use of ob_start() and ob_get_clean()

ob_start(); //Turn on output buffering ?>
Hello world, link
Content
$var = ob_get_clean(); ?>
//copy current buffer contents into $message variable and delete current output buffer

Leave a Reply