Home > Backend Development > PHP Tutorial > Sleeping problems have become a major headache for me sooner or later. . . -PHP, I will sleep with you...-php_PHP tutorial

Sleeping problems have become a major headache for me sooner or later. . . -PHP, I will sleep with you...-php_PHP tutorial

WBOY
Release: 2016-07-12 09:03:40
Original
1012 people have browsed it

Sleeping problems have become a major headache for me sooner or later. . . -PHP, I support you when sleeping...-php

 hi

Being myself again last night, I couldn’t sleep well and my whole body felt bad. . .

1. PHP realizes page staticization

2. Pure static

2.2 The principle of realizing pure static page

--Basic method

file_put_contents() function;

Use PHP’s built-in caching mechanism, output_buffering.

Detailed information can be found in the php manual. Focus on function format, parameters, and return values.

--Lizi file_put_contents()

/*
* Write function
*/

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

Run http://localhost/phpJingtaihua/index.shtml and get the result. A very simple function.

--Lizi output_buffering

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

Mainly involves four

ob_start, open the output control buffer;

ob_get_contents, returns the output buffer content;

ob_clean, clear the output buffer;

ob_get_clean, get the buffer content and delete the current output buffer.

ob_start(); //Open buffer
echo 1234;
echo ob_get_contents();

Get the sequence of 12341234. That is, all output goes through the buffer - like a filter on the faucet.

ob_start(); //Open 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 will no longer be output because of the buffer clearing, even the original echo statement will not work.

2.3 Introduction to pure static case implementation

The ultimate goal is to generate static files.

First, write data to static files.

Second, use the ob mechanism to obtain data (that can be written to static files).

2.4 Case implementation steps

Link to the database and obtain data from the database -> Fill the obtained data into the template file -> Convert dynamic pages into static pages and generate pure static files.

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

This is it for now, I will write it later if I have time at night. . . .

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1079204.htmlTechArticleSleeping problems have become a major headache for me sooner or later. . . -PHP, I love sleeping... -php hi I acted like myself again last night and couldn’t sleep well. . . 1. PHP realizes page staticization 2. Pure static...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template