PHP page Static-to achieve the principle of pure static page

Source: Internet
Author: User

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;







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.