: 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.