Let's look at some basic concepts first.
One, PHP script and dynamic page.
PHP script is a server-side scripting, can be embedded and other methods and HTML files mixed, but also class, function encapsulation, such as the form of templates to the user request processing. In any way, the rationale for it is this. The client requests a page-----> Web server to introduce the specified script for processing-----> script is loaded into the server-----> The PHP parser specified by the server parses the script to form an HTML language----> The parsed HTML statement is passed back to the browser as a package. It is not difficult to see that after the page is sent to the browser, PHP does not exist, has been transformed into HTML statements. Customer request for a dynamic file, in fact, there is no real file exists there, PHP is parsed into a corresponding page, and then sent back to the browser. This type of page processing is called a "dynamic page".
Second, static page.
A static page is a page that does exist on the server side with only HTML and client-run scripts such as JS,CSS. The way it's handled is. The client requests a page----> Web server to confirm and load a page----> the Web server passes the page back to the browser as a package. By this process, we compare the dynamic page, you can square now. Dynamic pages need to be resolved by the PHP parser of the Web server, and usually need to connect the database, do database access operation, then form the HTML language packet, and static page, no need to parse, no need to connect the database, send directly, can greatly reduce the server pressure, improve the server load capacity, Dramatically provide page opening speed and overall site opening speed. However, the disadvantage is that the request cannot be processed dynamically, and the file must exist on the server.
Third, template and template analysis.
The template is not yet populated with the content HTML file. For example:
Temp.html
Code:
The following is a reference fragment:
<HTML>
<title>{TITLE}</title>
<BODY>
This is a {file} file ' s templets
</BODY>
</HTML>
PHP Processing:
The following is a reference fragment:
templetest.php
Code:
$title = "HP Enthusiasts test template";
$file = "Twomax Inter test Templet,
Author:sheyi ";
$fp = fopen ("temp.html", "R");
$content = Fread ($fp, FileSize ("temp.html"));
$content. = Str_replace ("{file}", $file, $content);
$content. = Str_replace ("{title}", $title, $content);
Echo $content;
?>
Template parsing processing, the PHP script will be resolved after processing the results of the fill (content) into the template processing process. Typically, the use of template classes. At present, the more popular template parsing class has phplib,smarty,fastsmarty and so on. The rationale for template parsing is usually replacement. Also some programmers are accustomed to the judgment, loop and other processing into the template file, with the Analytic class processing, the typical application of the block concept, simply for a circular processing. By the PHP script to specify the number of cycles, how to loop generation, and then by the template parsing class to implement these operations. 1 2 3 Next page > Full text reading tips: Try "←→" button, turn the page more convenient Oh!