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.
ob_start(); echo("Hello First!"); $output = ob_get_contents(); ob_end_clean(); // data outputs when ob_start(); echo "Hello Second!<br/>"; ob_end_flush(); // data outputs with this function ob_start(); echo "Hello Third!\n"; $var = "<br/>help"; ob_end_clean(); ob_start(); echo "Hello Fourth!\n"; //ob_end_clean(); echo $var."<br/>"; echo $output; echo '<br/><br/>'.ob_get_contents(); // outputs the variables but does not echo
© 2018 ALL Rights Reserved | Sitemap
Vancouver | North Vancouver | Burnaby | Richmond | Coquitlam | Port Coquitlam | Surrey | Langley | Maple Ridge | Mission | Abbotsford | Kamloops | Kelowna | Victoria | Squamish | Whistler | Pemberton