It is best to print only required data which should be displayed to users, but sometimes we need to remove previously echoed / printed items based on certain condition.

In PHP, we use  ob_start()  function at the start of the script to store data in the buffer which is going to be sent to browser. Buffered items will be sent to browser at the end of the script or when we use methods like   ob_end_flush()  ,   ob_get_clean() 

Inbetween if you think to remove items stored in the buffer then  ob_end_clean()  will be handy.

Have a look at this example:

ob_start();
echo "abs";
print "bbc";
ob_end_clean();

echo "no items";


By using ob_end_clean only "no items" will be printed in the browser
 


Comments (0)
Leave a Comment

loader Posting your comment...