Hi
Last night to make himself, not sleep well the whole person is not good ...
1, PHP implementation of the page static
Second, pure static
2.2 Realization of the principle of pure static page
--Basic mode
File_put_contents () function;
Using the PHP built-in caching mechanism, output_buffering.
Specific information can be found in the PHP manual. Focus on function format, parameter, return value.
--Chestnut file_put_contents ()
/*
* Write function
*/
File_put_contents (' index.shtml ', ' asdklfj ');
Run http://localhost/phpJingtaihua/index.shtml to get results. A very simple function.
--Chestnut output_buffering
There are built-in functions, OB (output_buffering) series.
Mainly involving four
Ob_start, open the output control buffer;
Ob_get_contents, returns the output buffer contents;
Ob_clean, emptying the output buffer;
Ob_get_clean, gets the buffer contents and deletes the current output buffer.
Ob_start (); Open buffer
echo 1234;
Echo ob_get_contents ();
Get a sequence of 12341234. That is, all the output is going through the buffer-it's like having 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 because the buffer clears, and no longer outputs, even the original echo statement.
2.3 Pure Static Case Implementation Introduction
The ultimate goal is to generate static files.
One is to write the data to a static file.
Secondly, the OB mechanism is used to obtain data (which can be written to a static file).
2.4 Case Implementation Steps
Link the database, get the data from the database--"fill in the data to the template file-" The dynamic page into a static page, generate a pure static file.
-----------------
First, there is time to write again in the evening ....
The above is the introduction of sleep problems sooner or later become my top headache problem ... -php, including the aspects of the content, want to be interested in PHP tutorial friends helpful.