Sleeping problems will become a headache for me sooner or later... -PHP

Source: Internet
Author: User
: This article mainly introduces the problem of sleeping, which will become a headache for me sooner or later... -PHP: If you are interested in the PHP Tutorial, refer to it. Hi

I made myself again last night. the whole person was not good at sleeping well...

1. PHP static pages

II. Static

2.2 Principle of pure static page

-- Basic method

File_put_contents () function;

Use the php built-in Cache mechanism, output_buffering.

For more information, see The php Manual. Focus on the function format, parameters, and returned values.

-- Chestnut file_put_contents ()

/*
* Write function
*/

File_put_contents('index.shtml ', 'asdklfj ');

Run http: // localhost/phpJingtaihua/index.shtml. The result is displayed. A simple function.

-- Chestnut output_buffering

There are built-in functions, ob (output_buffering) series.

It mainly involves four

Ob_start: enable the output control buffer;

Ob_get_contents, return the output buffer content;

Ob_clean: clears the output buffer;

Ob_get_clean: Get the buffer content and delete the current output buffer.

Ob_start (); // open the buffer
Echo 1234;
Echo ob_get_contents ();

Obtain the sequence of 12341234. That is to say, all outputs need to go through the buffer zone-as if a filter nozzle is installed on the faucet.

Ob_start (); // open the buffer
Echo 111; echo"
";
Echo ob_get_contents (); echo"
";
Ob_clean ();
Echo ob_get_contents (); echo"
";

Echo 222; echo"
";

Echo ob_get_clean (); echo"
";

Here, 111 is not output because the buffer is cleared, even the original echo statement.

2.3 Introduction to pure static case

The ultimate goal is to generate static files.

First, write data to a static file.

Second, the ob mechanism is used to obtain (data that can be written to a static file.

2.4 case implementation steps

Link to the database to get data from the database -- fill in the obtained data to the template file -- convert the dynamic page into a static page and generate a pure static file.

-----------------

First, you have time to write it at night ....

The above introduces the sleeping problem that will become a headache for me sooner or later... -PHP, including some content, may be helpful to anyone interested in PHP tutorials.

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.