PHP ob_start()

ob_start PHP

The ob_start()function turns output buffering on. ob_start is often used with either the ob_end_flush() function or ob_end_clean() function. Basically, ob_start() will not display any printed text after the function is called, unless you use the ob_end_flush() function.

Alternatively, if you use the ob_end_clean() function to close a block after using ob_start() function, the variables are available, but, the printed(echoed) text will not display.

The coding sample below demonstrates how ob_start(), ob_end_flush() and ob_end_clean() functions operate.

        echo("Hello First!"); 
        $output = ob_get_contents();
        ob_end_clean(); // data outputs when 
            echo "Hello Second!<br/>";
            ob_end_flush(); // data outputs with this function
            echo "Hello Third!\n";
			$var = "<br/>help";
             echo "Hello Fourth!\n";
			 echo $var."<br/>";
			 echo $output;
			 echo '<br/><br/>'.ob_get_contents(); // outputs the variables but does not echo