Home >Backend Development >PHP Tutorial >How to use ob_start to generate html page in PHP_PHP tutorial
ob_start ([string output_callback]) - Open the output buffer
All output information is no longer sent directly to the browser, but is saved in the output buffer. An optional callback function is used to process the output result information.
ob_end_flush - End (send) the contents of the output buffer, close the output buffer
Using the output control function allows us to freely control the output of data in the script, which is useful when we want to output before the header.
The code is as follows:
Most of my personal use of OB is when generating static HTML. When a page will not be refreshed, and when other users browse this page again, the program will no longer call PHP and related database tutorials. At this time, it is a good practice to use ob to generate html.
The code is as follows: