PHP uses ob_start to generate html pages
Ob_start ([string output_callback])-open the output buffer
All output information is not directly sent to the browser, but saved in the output buffer. An optional callback function is used to process output result information.
Ob_end_flush-end (send) output buffer content, disable the output buffer
The output control function allows you to freely control the output of data in the script, which is useful when we want to output data before the header.
The Code is as follows:
<? Php
Ob_start (); // open the buffer
Echo "output n"; // output
Header ("header information ");
Ob_end_flush (); // output all content to the browser
?>
Most people use ob when generating static html, when a page is not refreshed, when other users browse this page again, the program will no longer call php and related database tutorials. In this case, using ob to generate html is a good practice.
The Code is as follows:
<? Php
Ob_start ();
If (@ readfile ($ tem_path) {// write the content in the specified path to the cache. If not, false is returned (that is, a PHP file you want to convert to html)
$ Content = ob_get_contents (); // obtain the cached content.
$ Fp = fopen ("1.html", "w"); // create a file, open it, and write
Fwrite ($ fp, $ content); // write the content of the PHP page to 1.html
}
Fclose ($ fp );
Ob_clean ();
?>