The ultimate goal of PHP is to create pure HTML files, and this pure HTML file is stored in the server's disk;
PHP implementation of the page to achieve pure static things:
1. File Write function
File_put_contents (), or fopen (), fwrite (), fclose () and other functions;
2. Buffer (cache) Operation function
OB function (Ob_start (), ob_get_contents (), Ob_clear (), Ob_get_clearn (), etc.);
Ob_start ()-Open "output control buffer";
Ob_get_contents ()-Returns the "contents of the output buffer";
Ob_clearn ()-Empty (erase) "Output buffer";
Ob_get_clearn ()-Gets the contents of the current buffer and deletes the current "output buffer";
In the previous article, once said, when we are executing a PHP program, if the PHP program has data output, then this data will first output
To the PHP buffer before the buffer transmits the data over TCP to the client and displays it;
So with the above OB function (output control buffer function), we can control the output of the buffer to achieve our goal, that is, to achieve
The static of the page;
The process is as follows:
First of all, when we execute a PHP program with output data, we should open the "control buffer" before outputting the data, and let the data output to the buffer;
Secondly, we can get the data of the buffer through the OB function;
The retrieved data is then written to an HTML file using the "File Write function", which is a purely static HTML file;
Therefore, we can directly access the generated pure static HTML file to achieve and access to dynamic PHP files The same purpose, so that the program more efficient operation;