Technology

why ob_start() and ob_get_clean() are so important

Basically ob_start() create buffer so that without using echo again and again we can get all html in the variable ob_get_clean() ob_get_clean() does 3 things for us in a single call function. It goes as follows: Fetch buffered content. Clean buffered content Shut off buffering. For example We can write code snippet like below   $output = ''; $output .= '<h1>Dummy</h1>'; if(true === $c ){ //here c is some condition. $output . = '<div>In loop</div>'; } $output .= '<div>End</div>'; echo $output; But when talk to good coding then it is not good practice